Пример #1
0
        public static UpdateElement VisitUpdatedElement(UpdatedElementContext context)
        {
            var         columnName = ExpressionVisitor.VisitFullColumnName(context.fullColumnName());
            IExpression expression;

            if (context.expression() != null)
            {
                expression = ExpressionVisitor.VisitExpression(context.expression());
            }
            else if (context.arrayExpression() != null)
            {
                expression = ExpressionVisitor.VisitArrayExpression(context.arrayExpression());
            }
            else if (context.arrayAddExpression() != null)
            {
                expression = ExpressionVisitor.VisitArrayAddExpression(context.arrayAddExpression());
            }
            else
            {
                expression = new LiteralExpression
                {
                    Value     = null,
                    ValueType = LiteralValueType.Null
                };
            }

            return(new UpdateElement
            {
                Name = columnName.Name,
                Value = expression,
            });
        }
Пример #2
0
        public static PrimarSqlSetColumnExpressionNode VisitUpdatedElement(UpdatedElementContext context)
        {
            var column = IdentifierVisitor.VisitFullColumnName(context.fullColumnName());

            var assignNode = new PrimarSqlSetColumnExpressionNode
            {
                Target = column.Name,
            };

            assignNode.Accessors.AddRange(column.Accessors);

            QsiExpressionNode expression;

            if (context.expression() != null)
            {
                expression = VisitExpression(context.expression());
            }
            else if (context.arrayExpression() != null)
            {
                expression = VisitArrayExpression(context.arrayExpression());
            }
            else if (context.arrayAddExpression() != null)
            {
                expression = VisitArrayAddExpression(context.arrayAddExpression());
            }
            else
            {
                expression = TreeHelper.CreateNullLiteral();
            }

            assignNode.Value.SetValue(expression);

            PrimarSqlTree.PutContextSpan(assignNode, context);
            return(assignNode);
        }