示例#1
0
        public override string Generate(DeleteSequenceExpression expression)
        {
            var result = new StringBuilder("DROP SEQUENCE ");

            result.AppendFormat(Quoter.QuoteSequenceName(expression.SequenceName, expression.SchemaName));
            return(result.ToString());
        }
        private void DeleteSequenceForIdentity(string tableName, string columnName)
        {
            CheckTable(tableName);
            LockTable(tableName);

            string sequenceName;

            try{
                sequenceName = GetSequenceName(tableName, columnName);
            }
            catch (ArgumentException)
            {
                return;
            }

            DeleteSequenceExpression deleteSequence = null;

            if (SequenceExists(string.Empty, sequenceName))
            {
                deleteSequence = new DeleteSequenceExpression()
                {
                    SchemaName = string.Empty, SequenceName = sequenceName
                };
            }
            string triggerName = GetIdentityTriggerName(tableName, columnName);
            PerformDBOperationExpression deleteTrigger = DeleteTriggerExpression(tableName, triggerName);

            Process(deleteTrigger);

            if (deleteSequence != null)
            {
                Process(deleteSequence);
            }
        }
示例#3
0
        public void CanDeleteSequenceWithoutSchemaName()
        {
            var expression = new DeleteSequenceExpression {
                SequenceName = "Sequence"
            };
            var sql = generator.Generate(expression);

            sql.ShouldBe("DROP SEQUENCE \"Sequence\"");
        }
        /// <inheritdoc />
        public IInSchemaSyntax Sequence(string sequenceName)
        {
            var expression = new DeleteSequenceExpression {
                SequenceName = sequenceName
            };

            _context.Expressions.Add(expression);
            return(new DeleteSequenceExpressionBuilder(expression));
        }
        public void CanDeleteSequence()
        {
            var expression = new DeleteSequenceExpression {
                SchemaName = "TestSchema", SequenceName = "Sequence"
            };
            var sql = generator.Generate(expression);

            sql.ShouldBe("DROP SEQUENCE [TestSchema].[Sequence]");
        }
示例#6
0
        public void ErrorIsReturnedWhenSequenceNameIsEmptyString()
        {
            var expression = new DeleteSequenceExpression {
                SequenceName = String.Empty
            };

            var errors = ValidationHelper.CollectErrors(expression);

            errors.ShouldContain(ErrorMessages.SequenceNameCannotBeNullOrEmpty);
        }
示例#7
0
        public void ErrorIsNotReturnedWhenSequenceNameIsSet()
        {
            var expression = new DeleteSequenceExpression {
                SequenceName = "sequence1"
            };

            var errors = ValidationHelper.CollectErrors(expression);

            Assert.That(errors.Count, Is.EqualTo(0));
        }
示例#8
0
        public void WhenDefaultSchemaConventionIsAppliedAndSchemaIsNotSetThenSchemaShouldBeNull()
        {
            var expression = new DeleteSequenceExpression {
                SequenceName = "sequence1"
            };

            var processed = expression.Apply(ConventionSets.NoSchemaName);

            Assert.That(processed.SchemaName, Is.Null);
        }
示例#9
0
        public void WhenDefaultSchemaConventionIsAppliedAndSchemaIsSetThenSchemaShouldNotBeChanged()
        {
            var expression = new DeleteSequenceExpression {
                SchemaName = "testschema", SequenceName = "sequence1"
            };

            var processed = expression.Apply(ConventionSets.WithSchemaName);

            Assert.That(processed.SchemaName, Is.EqualTo("testschema"));
        }
示例#10
0
        public void WhenDefaultSchemaConventionIsChangedAndSchemaIsNotSetThenSetSchema()
        {
            var expression = new DeleteSequenceExpression {
                SequenceName = "sequence1"
            };

            var processed = expression.Apply(ConventionSets.WithSchemaName);

            Assert.That(processed.SchemaName, Is.EqualTo("testdefault"));
        }
        public void WhenDefaultSchemaConventionIsAppliedAndSchemaIsSetThenSchemaShouldNotBeChanged()
        {
            var expression = new DeleteSequenceExpression {
                SchemaName = "testschema", SequenceName = "sequence1"
            };

            expression.ApplyConventions(new MigrationConventions());

            Assert.That(expression.SchemaName, Is.EqualTo("testschema"));
        }
        public void WhenDefaultSchemaConventionIsAppliedAndSchemaIsNotSetThenSchemaShouldBeNull()
        {
            var expression = new DeleteSequenceExpression {
                SequenceName = "sequence1"
            };

            expression.ApplyConventions(new MigrationConventions());

            Assert.That(expression.SchemaName, Is.Null);
        }
        public void CanDeleteSequence()
        {
            var expression = new DeleteSequenceExpression {
                SchemaName = "Schema", SequenceName = "Sequence"
            };
            var sql = generator.Generate(expression);

            sql.ShouldBe("DROP SEQUENCE Schema.Sequence");

            sql = quotedIdentiferGenerator.Generate(expression);
            sql.ShouldBe("DROP SEQUENCE \"Schema\".\"Sequence\"");
        }
        public void WhenDefaultSchemaConventionIsChangedAndSchemaIsNotSetThenSetSchema()
        {
            var expression = new DeleteSequenceExpression {
                SequenceName = "sequence1"
            };
            var migrationConventions = new MigrationConventions {
                GetDefaultSchema = () => "testdefault"
            };

            expression.ApplyConventions(migrationConventions);

            Assert.That(expression.SchemaName, Is.EqualTo("testdefault"));
        }
示例#15
0
        private void DeleteSequenceForIdentity(string tableName, string columnName)
        {
            CheckTable(tableName);
            LockTable(tableName);

            string sequenceName;

            try{
                sequenceName = GetSequenceName(tableName, columnName);
            }
            catch (ArgumentException)
            {
                return;
            }

            DeleteSequenceExpression deleteSequence = null;

            if (SequenceExists(String.Empty, sequenceName))
            {
                deleteSequence = new DeleteSequenceExpression()
                {
                    SchemaName = String.Empty, SequenceName = sequenceName
                };
            }
            string triggerName = GetIdentityTriggerName(tableName, columnName);
            PerformDBOperationExpression    deleteTrigger = DeleteTriggerExpression(tableName, triggerName);
            FirebirdProcessedExpressionBase fbExpression  = new FirebirdProcessedExpression <PerformDBOperationExpression>(deleteTrigger, this);
            FirebirdSchemaProvider          schema        = new FirebirdSchemaProvider(this);
            List <TriggerInfo> triggers = schema.GetTableSchema(tableName).Triggers;

            foreach (TriggerInfo trigger in triggers)
            {
                if (trigger.Name.ToUpper() == triggerName.ToUpper())
                {
                    PerformDBOperationExpression createTrigger = CreateTriggerExpression(tableName, trigger);
                    if (this.FBOptions.UndoEnabled)
                    {
                        fbExpression.AddUndoExpression(createTrigger);
                    }
                    break;
                }
            }
            RegisterExpression(fbExpression);
            Process(deleteTrigger);

            if (deleteSequence != null)
            {
                Process(deleteSequence);
            }
        }
示例#16
0
        public override string Generate(DeleteSequenceExpression expression)
        {
            var result = new StringBuilder(string.Format("DROP SEQUENCE "));

            if (string.IsNullOrEmpty(expression.SchemaName))
            {
                result.AppendFormat(Quoter.QuoteSequenceName(expression.SequenceName));
            }
            else
            {
                result.AppendFormat("{0}.{1}", Quoter.QuoteSchemaName(expression.SchemaName), Quoter.QuoteSequenceName(expression.SequenceName));
            }

            return(result.ToString());
        }
示例#17
0
        protected void SetupUndoDeleteSequence(DeleteSequenceExpression expression)
        {
            CanUndo = true;
            FirebirdSchemaProvider   schema         = new FirebirdSchemaProvider(Processor);
            SequenceInfo             sequence       = schema.GetSequence(expression.SequenceName);
            CreateSequenceExpression createSequence = new CreateSequenceExpression()
            {
                Sequence = new SequenceDefinition()
                {
                    Name      = sequence.Name,
                    StartWith = sequence.CurrentValue
                }
            };

            UndoExpressions.Add(createSequence);
        }
示例#18
0
 public override void Process(DeleteSequenceExpression expression)
 {
     truncator.Truncate(expression);
     RegisterExpression <DeleteSequenceExpression>(expression);
     InternalProcess(Generator.Generate(expression));
 }
示例#19
0
 public abstract string Generate(DeleteSequenceExpression expression);
示例#20
0
 public override string Generate(DeleteSequenceExpression expression)
 {
     throw new NotImplementedException();
 }
示例#21
0
 public override string Generate(DeleteSequenceExpression expression)
 {
     return compatabilityMode.HandleCompatabilty("Sequences is not supporteed for MySql");
 }
 public override void Process(DeleteSequenceExpression expression)
 {
     base.Process(expression.ToLower());
 }
示例#23
0
 public static DeleteSequenceExpression ToLower(this DeleteSequenceExpression expresstion)
 {
     expresstion.SequenceName = expresstion.SequenceName.ToLower();
     return(expresstion);
 }
 public override string Generate(DeleteSequenceExpression expression)
 {
     return(CompatibilityMode.HandleCompatibilty("Sequences not supported"));
 }
示例#25
0
 public void Truncate(DeleteSequenceExpression expression)
 {
     expression.SequenceName = Truncate(expression.SequenceName);
 }
 public override string Generate(DeleteSequenceExpression expression)
 {
     return(compatabilityMode.HandleCompatabilty("Sequences are not supported in SqlAnywhere"));
 }
示例#27
0
 public override string Generate(DeleteSequenceExpression expression)
 {
     Truncator.Truncate(expression);
     return(String.Format("DROP SEQUENCE {0}", Quoter.QuoteSequenceName(expression.SequenceName)));
 }
示例#28
0
 public virtual void Process(DeleteSequenceExpression expression)
 {
     Process(Generator.Generate(expression));
 }
示例#29
0
 public override string Generate(DeleteSequenceExpression expression)
 {
     return(compatabilityMode.HandleCompatabilty("Sequences is not supporteed for MySql"));
 }
示例#30
0
 public override string Generate(DeleteSequenceExpression expression)
 {
     return(string.Format("{0};", base.Generate(expression)));
 }
 public override string Generate(DeleteSequenceExpression expression)
 {
     return($"DROP SEQUENCE {Quoter.QuoteSequenceName(expression.SequenceName, expression.SchemaName)}");
 }