Ejemplo n.º 1
0
 public SingleQuery(SingleQueryClause singleQueryClause
                    , OrderBy orderBy
                    , ILimitClause limit)
     : this(singleQueryClause.Quantifier
            , singleQueryClause.HasTop
            , singleQueryClause.Top
            , singleQueryClause.HasWildcard
            , singleQueryClause.Results
            , singleQueryClause.From
            , singleQueryClause.Where
            , singleQueryClause.GroupBy
            , singleQueryClause.Having
            , orderBy
            , limit
            , singleQueryClause.Comments)
 {
 }
 void IVisitor.VisitOnWhere(SingleQueryClause queryClause, int offset)
 {
     this.ParentExists(queryClause);
 }
        //void IVisitor.VisitBefore(BracketedQuery bracketedQuery) {
        //  this.ParentExists(bracketedQuery);
        //}

        //void IVisitor.VisitBefore(CompoundQuery compoundQuery) {
        //  this.ParentExists(compoundQuery);
        //}

        //void IVisitor.VisitBefore(SingleQuery query) {
        //  this.ParentExists(query);
        //}

        void IVisitor.VisitBefore(SingleQueryClause queryClause)
        {
            this.ParentExists(queryClause);
        }
        //void IVisitor.VisitAfter(BracketedQuery bracketedQuery) {
        //  this.ParentExists(bracketedQuery);
        //}

        //void IVisitor.VisitAfter(CompoundQuery compoundQuery) {
        //  this.ParentExists(compoundQuery);
        //}

        //void IVisitor.VisitAfter(SingleQuery query) {
        //  this.ParentExists(query);
        //}

        void IVisitor.VisitAfter(SingleQueryClause queryClause)
        {
            this.ParentExists(queryClause);
        }
Ejemplo n.º 5
0
        public override Assignments GetAssignments(int index)
        {
            //  テーブル列名の指定がない場合は、空のAssignmentsを返す
            if (this.Columns == null || this.Columns.Count == 0)
            {
                return(new Assignments());
            }

            // Compound Queryの場合は空のAssignmentsを返す
            SingleQueryClause singleQuery = null;

            if (this.Query.Type == QueryType.Compound)
            {
                return(new Assignments());
            }
            else if (this.Query.Type == QueryType.Bracketed)
            {
                IQueryClause query = ((BracketedQuery)this.Query).Operand;
                // 括弧を剥ぐ
                while (query.Type == QueryType.Bracketed)
                {
                    query = ((BracketedQueryClause)query).Operand;
                }
                if (query.Type != QueryType.Single)
                {
                    return(new Assignments());
                }
                singleQuery = (SingleQueryClause)query;
            }
            else
            {
                singleQuery = (SingleQuery)this.Query;
            }

            // SELECT *の場合は空のAssignmentsを返す
            if (singleQuery.HasWildcard)
            {
                return(new Assignments());
            }

            // テーブル列名とSELECT句の要素数が異なる場合はエラーとする
            if (this.Columns.Count != singleQuery.Results.Count)
            {
                throw new InvalidASTStructureError("テーブル列名とSELECT句の要素数が異なります");
            }

            var ret = new Assignments();

            for (var i = 0; i < Columns.Count; ++i)
            {
                var column = new Column(this.Columns[i].Name);
                var result = singleQuery.Results[i];
                // SELECT句にTable WildCardが含まれる場合は、空のAssignmentsを返す
                if (result.IsTableWildcard)
                {
                    return(new Assignments());
                }
                var value      = ((ResultExpr)result).Value;
                var assignment = new Assignment(column, value);
                ret.Add(assignment);
            }

            return(ret);
        }
Ejemplo n.º 6
0
 internal SingleQuery(SingleQueryClause singleQueryClause)
     : this(singleQueryClause
            , new OrderBy()
            , null)
 {
 }