コード例 #1
0
 public static QsiTableExpressionNode VisitSelectStatement(SelectStatementContext context)
 {
     return(TreeHelper.Create <QsiTableExpressionNode>(n =>
     {
         n.Table.SetValue(TableVisitor.VisitSelectStatement(context));
     }));
 }
コード例 #2
0
        public static QsiActionNode VisitInsertStatement(InsertStatementContext context)
        {
            var node = new QsiDataInsertActionNode
            {
                ConflictBehavior = context.IGNORE() != null ? QsiDataConflictBehavior.Ignore : QsiDataConflictBehavior.None
            };

            if (context.tableName() == null)
            {
                throw new QsiException(QsiError.Syntax);
            }

            node.Target.SetValue(TableVisitor.VisitTableName(context.tableName()));

            switch (context.insertStatementValue())
            {
            case SubqueryInsertStatementContext _:
            {
                throw TreeHelper.NotSupportedFeature("subquery insert");
            }

            case ExpressionInsertStatementContext expressionContext:
            {
                if (context.columns != null)
                {
                    node.Columns = context.columns.uid()
                                   .Select(i => new QsiQualifiedIdentifier(IdentifierVisitor.VisitUid(i)))
                                   .ToArray();
                }

                IEnumerable <QsiRowValueExpressionNode> rows = expressionContext
                                                               .expressionsWithDefaults()
                                                               .Select(ExpressionVisitor.VisitExpressionsWithDefaults);

                node.Values.AddRange(rows);
                break;
            }

            case JsonInsertStatementContext jsonContext:
            {
                (JObject, JsonObjectContext x)[] objects = jsonContext.jsonObject()