コード例 #1
0
        public static ITableSource VisitTableSourceBase(TableSourceItemContext context)
        {
            IPart[] identifiers = IdentifierUtility.Parse(context.tableName().GetText());
            ValidateTableWithIndexName(identifiers);

            return(new AtomTableSource(
                       identifiers[0].ToString(),
                       identifiers.Length == 2 ? identifiers[1].ToString() : string.Empty
                       ));
        }
コード例 #2
0
        public List <FromItem> ParseTableSources(TableSourcesContext node)
        {
            List <FromItem> fromItems = new List <FromItem>();

            TableSourceContext[] tables = node.tableSource();

            foreach (TableSourceContext table in tables)
            {
                if (table is TableSourceBaseContext tb)
                {
                    TableSourceItemContext tsi = tb.tableSourceItem();
                    FromItem fromItem          = new FromItem();

                    if (tsi is SubqueryTableItemContext subquery)
                    {
                        fromItem.SubSelectStatement = this.ParseSelectStatement(subquery.selectStatement());

                        UidContext uid = subquery.uid();

                        if (uid != null)
                        {
                            fromItem.Alias = new TokenInfo(uid)
                            {
                                Type = TokenType.Alias
                            };
                        }
                    }
                    else
                    {
                        TableName tableName = this.ParseTableName(tsi);

                        fromItem.TableName = tableName;

                        JoinPartContext[] joins = tb.joinPart();

                        if (joins != null && joins.Length > 0)
                        {
                            foreach (JoinPartContext join in joins)
                            {
                                JoinItem joinItem = this.ParseJoin(join);

                                fromItem.JoinItems.Add(joinItem);
                            }
                        }
                    }

                    fromItems.Add(fromItem);
                }
            }

            return(fromItems);
        }
コード例 #3
0
        public static QsiTableNode VisitTableSourceItem(TableSourceItemContext context)
        {
            switch (context)
            {
            case AtomTableItemContext atomTableItemContext:
                return(VisitAtomTableItem(atomTableItemContext));

            case SubqueryTableItemContext subqueryTableItemContext:
                return(VisitSubqueryTableItem(subqueryTableItemContext));
            }

            throw TreeHelper.NotSupportedTree(context);
        }
コード例 #4
0
 public static QsiTableNode VisitTableSourceItem(TableSourceItemContext context)
 {
     return(VisitTableName(context.tableName()));
 }