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); } }
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]"); }
public void ErrorIsReturnedWhenSequenceNameIsEmptyString() { var expression = new DeleteSequenceExpression { SequenceName = String.Empty }; var errors = ValidationHelper.CollectErrors(expression); errors.ShouldContain(ErrorMessages.SequenceNameCannotBeNullOrEmpty); }
public void ErrorIsNotReturnedWhenSequenceNameIsSet() { var expression = new DeleteSequenceExpression { SequenceName = "sequence1" }; var errors = ValidationHelper.CollectErrors(expression); Assert.That(errors.Count, Is.EqualTo(0)); }
public void WhenDefaultSchemaConventionIsAppliedAndSchemaIsNotSetThenSchemaShouldBeNull() { var expression = new DeleteSequenceExpression { SequenceName = "sequence1" }; var processed = expression.Apply(ConventionSets.NoSchemaName); Assert.That(processed.SchemaName, Is.Null); }
public void WhenDefaultSchemaConventionIsAppliedAndSchemaIsSetThenSchemaShouldNotBeChanged() { var expression = new DeleteSequenceExpression { SchemaName = "testschema", SequenceName = "sequence1" }; var processed = expression.Apply(ConventionSets.WithSchemaName); Assert.That(processed.SchemaName, Is.EqualTo("testschema")); }
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")); }
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); } }
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()); }
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); }
public override void Process(DeleteSequenceExpression expression) { truncator.Truncate(expression); RegisterExpression <DeleteSequenceExpression>(expression); InternalProcess(Generator.Generate(expression)); }
public abstract string Generate(DeleteSequenceExpression expression);
public override string Generate(DeleteSequenceExpression expression) { throw new NotImplementedException(); }
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()); }
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")); }
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")); }
public override string Generate(DeleteSequenceExpression expression) { Truncator.Truncate(expression); return(String.Format("DROP SEQUENCE {0}", Quoter.QuoteSequenceName(expression.SequenceName))); }
public virtual void Process(DeleteSequenceExpression expression) { Process(Generator.Generate(expression)); }
public override string Generate(DeleteSequenceExpression expression) { return(compatabilityMode.HandleCompatabilty("Sequences is not supporteed for MySql")); }
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)}"); }