public override IASTNode VisitTableFactor(SqlServerCommandParser.TableFactorContext context)
        {
            TableFactorSegment result = new TableFactorSegment();

            if (null != context.subquery())
            {
                var subquery             = (SelectCommand)Visit(context.subquery());
                var subquerySegment      = new SubQuerySegment(context.subquery().Start.StartIndex, context.subquery().Stop.StopIndex, subquery);
                var subqueryTableSegment = new SubQueryTableSegment(subquerySegment);
                if (null != context.alias())
                {
                    subqueryTableSegment.SetAlias((AliasSegment)Visit(context.alias()));
                }
                result.SetTable(subqueryTableSegment);
            }
            if (null != context.tableName())
            {
                SimpleTableSegment table = (SimpleTableSegment)Visit(context.tableName());
                if (null != context.alias())
                {
                    table.SetAlias((AliasSegment)Visit(context.alias()));
                }
                result.SetTable(table);
            }
            if (null != context.tableReferences())
            {
                var tableReferences = (CollectionValue <TableReferenceSegment>)Visit(context.tableReferences());
                result.TableReferences.AddAll(tableReferences.GetValue());
            }
            return(result);
        }
        public override IASTNode VisitJoinedTable(SqlServerCommandParser.JoinedTableContext context)
        {
            JoinedTableSegment result      = new JoinedTableSegment();
            TableFactorSegment tableFactor = (TableFactorSegment)Visit(context.tableFactor());

            result.SetTableFactor(tableFactor);
            if (null != context.joinSpecification())
            {
                result.SetJoinSpecification((JoinSpecificationSegment)Visit(context.joinSpecification()));
            }
            return(result);
        }
        public override IASTNode VisitTableReference(SqlServerCommandParser.TableReferenceContext context)
        {
            TableReferenceSegment result = new TableReferenceSegment();

            if (null != context.tableFactor())
            {
                TableFactorSegment tableFactor = (TableFactorSegment)Visit(context.tableFactor());
                result.SetTableFactor(tableFactor);
            }
            if (!context.joinedTable().IsEmpty())
            {
                foreach (var joinedTableContext in context.joinedTable())
                {
                    JoinedTableSegment joinedTableSegment = (JoinedTableSegment)Visit(joinedTableContext);
                    result.JoinedTables.Add(joinedTableSegment);
                }
            }
            return(result);
        }
Ejemplo n.º 4
0
        public override IASTNode VisitTableReference(MySqlCommandParser.TableReferenceContext ctx)
        {
            TableReferenceSegment result = new TableReferenceSegment();

            if (null != ctx.tableFactor())
            {
                TableFactorSegment tableFactor = (TableFactorSegment)Visit(ctx.tableFactor());
                result.SetTableFactor(tableFactor);
            }
            if (!ctx.joinedTable().IsEmpty())
            {
                foreach (MySqlCommandParser.JoinedTableContext each in ctx.joinedTable())
                {
                    JoinedTableSegment joinedTableSegment = (JoinedTableSegment)Visit(each);
                    result.JoinedTables.Add(joinedTableSegment);
                }
            }
            return(result);
        }