示例#1
0
        protected virtual void ProcessOffsetOrLimit(SQLProcessorAggregator aggregator, StringBuilder builder, NonBooleanExpression expr, Boolean isOffset)
        {
            var prefix = isOffset ? this.GetOffsetPrefix(aggregator.SQLVendor) : this.GetLimitPrefix(aggregator.SQLVendor);

            if (prefix != null)
            {
                builder.Append(prefix).Append(SQLConstants.TOKEN_SEPARATOR);
            }
            var isComplex = !(expr is LiteralExpression);

            if (isComplex)
            {
                builder.Append(SQLConstants.OPEN_PARENTHESIS + SQLConstants.NEWLINE);
            }
            aggregator.Process(expr, builder);
            if (isComplex)
            {
                builder.Append(SQLConstants.CLOSE_PARENTHESIS);
            }
            var postfix = isOffset ? this.GetOffsetPostfix(aggregator.SQLVendor) : this.GetLimitPostfix(aggregator.SQLVendor);

            if (postfix != null)
            {
                builder.Append(SQLConstants.TOKEN_SEPARATOR).Append(postfix);
            }
        }
示例#2
0
 protected override void DoProcessJoinedTable(SQLProcessorAggregator aggregator, NaturalJoinedTable obj, StringBuilder builder)
 {
     builder.Append(" NATURAL ");
     this.ProcessJoinType(obj.JoinType, builder);
     builder.Append(SQLConstants.TOKEN_SEPARATOR);
     aggregator.Process(obj.Right, builder);
 }
示例#3
0
 protected override void DoProcess(SQLProcessorAggregator aggregator, RegularViewSpecification obj, StringBuilder builder)
 {
     if (obj.Columns != null)
     {
         aggregator.Process(obj.Columns, builder);
     }
 }
示例#4
0
        protected override void DoProcess(SQLProcessorAggregator aggregator, MultiPredicate obj, StringBuilder builder, Boolean negationActive)
        {
            aggregator.Process(obj.Left, builder);
            builder.Append(SQLConstants.TOKEN_SEPARATOR).Append(negationActive ? this._negatedOperator : this._operator).Append(SQLConstants.TOKEN_SEPARATOR);
            if (this._needParenthesis)
            {
                builder.Append(SQLConstants.OPEN_PARENTHESIS);
            }

            ProcessorUtils.AppendEnumerable(aggregator, builder, obj.Rights, this._separator, (agg, b, exp) =>
            {
                var isQuery = exp is QueryExpression;
                if (isQuery)
                {
                    b.Append(SQLConstants.OPEN_PARENTHESIS);
                }
                agg.Process(exp, b);
                if (isQuery)
                {
                    b.Append(SQLConstants.CLOSE_PARENTHESIS);
                }
            });

            if (this._needParenthesis)
            {
                builder.Append(SQLConstants.CLOSE_PARENTHESIS);
            }
        }
示例#5
0
        protected override void DoProcess(SQLProcessorAggregator aggregator, UnaryPredicate <ValueExpression> obj, StringBuilder builder, Boolean negationActive)
        {
            var op = negationActive ? this._negatedOperator : this._operator;

            if (UnaryOperatorOrientation.BeforeExpression == this._orientation)
            {
                builder.Append(op).Append(SQLConstants.TOKEN_SEPARATOR);
            }
            var exp     = obj.Expression;
            var isQuery = exp is QueryExpression;

            if (isQuery)
            {
                builder.Append(SQLConstants.OPEN_PARENTHESIS);
            }
            aggregator.Process(exp, builder);
            if (isQuery)
            {
                builder.Append(SQLConstants.CLOSE_PARENTHESIS);
            }

            if (UnaryOperatorOrientation.AfterExpression == this._orientation)
            {
                builder.Append(SQLConstants.TOKEN_SEPARATOR).Append(op);
            }
        }
示例#6
0
 protected override void DoProcess(SQLProcessorAggregator aggregator, UnaryArithmeticExpression obj, StringBuilder builder)
 {
     this.ProcessArithmeticExpression(obj, builder);
     builder.Append(SQLConstants.OPEN_PARENTHESIS);
     aggregator.Process(obj.Expression, builder);
     builder.Append(SQLConstants.CLOSE_PARENTHESIS);
 }
示例#7
0
 protected override void DoProcess(SQLProcessorAggregator aggregator, Negation obj, StringBuilder builder, Boolean negationActive)
 {
     if (!obj.NegatedExpression.IsEmpty())
     {
         aggregator.Process(obj.NegatedExpression, builder, !negationActive);
     }
 }
示例#8
0
 protected override void DoProcess(SQLProcessorAggregator aggregator, T obj, StringBuilder builder)
 {
     if (obj.ColumnNames != null)
     {
         aggregator.Process(obj.ColumnNames, builder);
     }
     this.DoProcessColumnSource(aggregator, obj, builder);
 }
示例#9
0
 protected override void DoProcess(SQLProcessorAggregator aggregator, UpdateBySearch obj, StringBuilder builder)
 {
     builder.Append("UPDATE ");
     aggregator.Process(obj.TargetTable, builder);
     builder.Append(SQLConstants.NEWLINE).Append("SET ");
     ProcessorUtils.AppendEnumerable(aggregator, builder, obj.SetClauses, SQLConstants.COMMA + SQLConstants.TOKEN_SEPARATOR);
     ProcessorUtils.ProcessOptionalBooleanExpresssion(aggregator, builder, obj.Condition, SQLConstants.NEWLINE, SQLConstants.WHERE);
 }
示例#10
0
 protected virtual void ProcessTableAlias(SQLProcessorAggregator aggregator, TableAlias alias, StringBuilder builder)
 {
     builder.Append(SQLConstants.TOKEN_SEPARATOR + SQLConstants.ALIAS_DEFINER + SQLConstants.TOKEN_SEPARATOR).Append(alias.TableAlias);
     if (alias.ColumnAliases != null)
     {
         aggregator.Process(alias.ColumnAliases, builder);
     }
 }
示例#11
0
 protected void ProcessSchemaElements(SQLProcessorAggregator aggregator, SchemaDefinition obj, StringBuilder builder)
 {
     builder.Append(SQLConstants.NEWLINE);
     foreach (var el in obj.SchemaElements)
     {
         aggregator.Process(el, builder);
         builder.Append(SQLConstants.NEWLINE);
     }
 }
示例#12
0
 public static void ProcessNonOptional(SQLProcessorAggregator aggregator, ObjectWithVendor obj, StringBuilder builder, String prefix, String name)
 {
     builder.Append(prefix);
     if (name != null)
     {
         builder.Append(name).Append(SQLConstants.TOKEN_SEPARATOR);
     }
     aggregator.Process(obj, builder);
 }
示例#13
0
 protected override void DoProcess(SQLProcessorAggregator aggregator, CorrespondingSpec obj, StringBuilder builder)
 {
     builder.Append("CORRESPONDING");
     if (obj.ColumnNames != null)
     {
         builder.Append(SQLConstants.TOKEN_SEPARATOR + "BY" + SQLConstants.TOKEN_SEPARATOR);
         aggregator.Process(obj.ColumnNames, builder);
     }
 }
示例#14
0
        protected override void DoProcess(SQLProcessorAggregator aggregator, ViewDefinition obj, StringBuilder builder)
        {
            builder.Append(SQLConstants.CREATE);
            if (obj.IsRecursive)
            {
                builder.Append("RECURSIVE ");
            }
            builder.Append(SQLConstants.VIEW);

            aggregator.Process(obj.ViewName, builder);
            aggregator.Process(obj.ViewSpecification, builder);
            builder.Append(SQLConstants.ALIAS_DEFINER).Append(SQLConstants.NEWLINE);
            aggregator.Process(obj.ViewQuery, builder);

            if (obj.ViewCheckOption.HasValue)
            {
                builder.Append(SQLConstants.NEWLINE).Append(SQLConstants.WITH).Append(this._viewCheckOptions[obj.ViewCheckOption.Value]).Append(" CHECK OPTION");
            }
        }
示例#15
0
        protected override void DoProcess(SQLProcessorAggregator aggregator, TableDefinition obj, StringBuilder builder)
        {
            builder.Append(SQLConstants.CREATE);
            if (obj.TableScope.HasValue)
            {
                builder.Append(this._tableScopes[obj.TableScope.Value]).Append(SQLConstants.TOKEN_SEPARATOR);
            }
            builder.Append(SQLConstants.TABLE);

            aggregator.Process(obj.TableName, builder);
            builder.Append(SQLConstants.NEWLINE);

            aggregator.Process(obj.Contents, builder);
            builder.Append(SQLConstants.NEWLINE);

            if (obj.CommitAction.HasValue)
            {
                builder.Append("ON COMMIT ").Append(this._commitActions[obj.CommitAction.Value]);
            }
        }
示例#16
0
 protected override void DoProcess(SQLProcessorAggregator aggregator, BooleanTest obj, StringBuilder builder, Boolean negationActive)
 {
     builder.Append(SQLConstants.OPEN_PARENTHESIS);
     aggregator.Process(obj.Expression, builder);
     builder.Append(SQLConstants.CLOSE_PARENTHESIS).Append(SQLConstants.TOKEN_SEPARATOR).Append(SQLConstants.IS).Append(SQLConstants.TOKEN_SEPARATOR);
     if (negationActive)
     {
         builder.Append(SQLConstants.NOT).Append(SQLConstants.TOKEN_SEPARATOR);
     }
     builder.Append(obj.TruthValue.HasValue ? (obj.TruthValue.Value ? SQLConstants.TRUE : SQLConstants.FALSE) : SQLConstants.UNKNOWN);
 }
示例#17
0
        protected override void DoProcess(SQLProcessorAggregator aggregator, TableConstraintDefinition obj, StringBuilder builder)
        {
            if (obj.ConstraintName != null)
            {
                builder.Append("CONSTRAINT ").Append(obj.ConstraintName).Append(SQLConstants.TOKEN_SEPARATOR);
            }

            aggregator.Process(obj.Constraint, builder);

            if (obj.ConstraintCharacteristics.HasValue)
            {
                builder.Append(SQLConstants.TOKEN_SEPARATOR).Append(this._characteristics[obj.ConstraintCharacteristics.Value]);
            }
        }
示例#18
0
        protected override void DoProcess(SQLProcessorAggregator aggregator, ForeignKeyConstraint obj, StringBuilder builder)
        {
            builder.Append("FOREIGN KEY");
            aggregator.Process(obj.SourceColumns, builder);

            builder.Append(SQLConstants.NEWLINE).Append("REFERENCES ");
            aggregator.Process(obj.TargetTable, builder);

            if (obj.TargetColumns != null)
            {
                aggregator.Process(obj.TargetColumns, builder);
            }

            if (obj.MatchType.HasValue)
            {
                builder.Append(" MATCH ").Append(this._matchTypes[obj.MatchType.Value]);
            }
            builder.Append(SQLConstants.NEWLINE);

            this.HandleReferentialAction("ON UPDATE ", obj.OnUpdate, builder);
            builder.Append(SQLConstants.TOKEN_SEPARATOR);
            this.HandleReferentialAction("ON DELETE ", obj.OnDelete, builder);
        }
示例#19
0
        protected override void DoProcess(SQLProcessorAggregator aggregator, TargetTable obj, StringBuilder builder)
        {
            var isOnly = obj.IsOnly;

            if (isOnly)
            {
                builder.Append("ONLY").Append(SQLConstants.OPEN_PARENTHESIS);
            }
            aggregator.Process(obj.TableName, builder);
            if (isOnly)
            {
                builder.Append(SQLConstants.CLOSE_PARENTHESIS);
            }
        }
示例#20
0
        public static void AppendEnumerable <U>(SQLProcessorAggregator aggregator, StringBuilder builder, ImmutableArray <U> aq, String separator)
            where U : ObjectWithVendor
        {
            var array = aq.ArrayObject;

            for (var idx = 0; idx < array.Length; ++idx)
            {
                aggregator.Process(array[idx], builder);


                if (idx + 1 < array.Length)
                {
                    builder.Append(separator);
                }
            }
        }
示例#21
0
        protected override void DoProcess(SQLProcessorAggregator aggregator, DropTableOrViewStatement obj, StringBuilder builder)
        {
            builder.Append(SQLConstants.DROP + SQLConstants.TOKEN_SEPARATOR);
            switch (obj.WhatToDrop)
            {
            case ObjectType.Table:
                builder.Append(SQLConstants.TABLE);
                break;

            case ObjectType.View:
                builder.Append(SQLConstants.VIEW);
                break;
            }
            builder.Append(SQLConstants.TOKEN_SEPARATOR);

            this.BeforeTableName(aggregator, obj, builder);

            aggregator.Process(obj.TableName, builder);
            this.ProcessDropBehaviour(obj.DropBehaviour, builder);
        }
示例#22
0
 protected override void DoProcessActually(SQLProcessorAggregator aggregator, RowSubQuery obj, StringBuilder builder)
 {
     aggregator.Process(obj.Query, builder);
 }
示例#23
0
 protected override void DoProcessTableName(SQLProcessorAggregator aggregator, TableNameFunction obj, StringBuilder builder)
 {
     aggregator.Process(obj.Function, builder);
 }
示例#24
0
 protected override void DoProcess(SQLProcessorAggregator aggregator, JoinCondition obj, StringBuilder builder)
 {
     builder.Append(" ON ");
     aggregator.Process(obj.SearchCondition, builder);
 }
示例#25
0
 protected override void DoProcess(SQLProcessorAggregator aggregator, NamedColumnsJoin obj, StringBuilder builder)
 {
     builder.Append(" USING ");
     aggregator.Process(obj.ColumnNames, builder);
 }
示例#26
0
 protected override void DoProcessJoinedTable(SQLProcessorAggregator aggregator, UnionJoinedTable obj, StringBuilder builder)
 {
     builder.Append(" UNION JOIN ");
     aggregator.Process(obj.Right, builder);
 }
示例#27
0
 protected override void DoProcessJoinedTable(SQLProcessorAggregator aggregator, QualifiedJoinedTable obj, StringBuilder builder)
 {
     this.ProcessJoinType(obj.JoinType, builder);
     aggregator.Process(obj.Right, builder);
     aggregator.Process(obj.JoinSpecification, builder);
 }
示例#28
0
 protected override void DoProcessTableReferencePrimary(SQLProcessorAggregator aggregator, TableReferenceByName tRef, StringBuilder builder)
 {
     aggregator.Process(tRef.TableName, builder);
 }
示例#29
0
 protected override void DoProcess(SQLProcessorAggregator aggregator, T obj, StringBuilder builder)
 {
     aggregator.Process(obj.Left, builder);
     builder.Append(SQLConstants.NEWLINE);
     this.DoProcessJoinedTable(aggregator, obj, builder);
 }
示例#30
0
 protected override void DoProcessTableReferencePrimary(SQLProcessorAggregator aggregator, TableReferenceByQuery tRef, StringBuilder builder)
 {
     builder.Append(SQLConstants.OPEN_PARENTHESIS);
     aggregator.Process(tRef.Query, builder);
     builder.Append(SQLConstants.CLOSE_PARENTHESIS);
 }