/// <inheritdoc />
        public IDeleteConstraintOnTableSyntax UniqueConstraint()
        {
            var expression = new DeleteConstraintExpression(ConstraintType.Unique);

            _context.Expressions.Add(expression);
            return(new DeleteConstraintExpressionBuilder(expression));
        }
 public override string Generate(DeleteConstraintExpression expression)
 {
     return(string.Format(
                "ALTER TABLE {0} DROP CONSTRAINT {1};",
                Quoter.QuoteTableName(expression.Constraint.TableName, expression.Constraint.SchemaName),
                Quoter.Quote(expression.Constraint.ConstraintName)));
 }
Esempio n. 3
0
        public static DeleteConstraintExpression GetDeletePrimaryKeyExpression()
        {
            var expression = new DeleteConstraintExpression(ConstraintType.PrimaryKey);

            expression.Constraint.TableName      = TestTableName1;
            expression.Constraint.ConstraintName = "TESTPRIMARYKEY";
            return(expression);
        }
Esempio n. 4
0
 public override string Generate(DeleteConstraintExpression expression)
 {
     if (expression.Constraint.IsPrimaryKeyConstraint)
     {
         return(string.Format(DeleteConstraint, Quoter.QuoteTableName(expression.Constraint.TableName), "PRIMARY KEY", ""));
     }
     return(string.Format(DeleteConstraint, Quoter.QuoteTableName(expression.Constraint.TableName), "INDEX ", Quoter.Quote(expression.Constraint.ConstraintName)));
 }
Esempio n. 5
0
 public override string Generate(DeleteConstraintExpression expression)
 {
     if (expression.Constraint.IsPrimaryKeyConstraint)
     {
         return string.Format(DeleteConstraint, Quoter.QuoteTableName(expression.Constraint.TableName), "PRIMARY KEY", "");
     }
     return string.Format(DeleteConstraint, Quoter.QuoteTableName(expression.Constraint.TableName), "INDEX ", Quoter.Quote(expression.Constraint.ConstraintName));
 }
        /// <inheritdoc />
        public IDeleteConstraintOnTableSyntax PrimaryKey(string primaryKeyName)
        {
            var expression = new DeleteConstraintExpression(ConstraintType.PrimaryKey);

            expression.Constraint.ConstraintName = primaryKeyName;
            _context.Expressions.Add(expression);
            return(new DeleteConstraintExpressionBuilder(expression));
        }
Esempio n. 7
0
        public static DeleteConstraintExpression GetDeleteUniqueConstraintExpression()
        {
            var expression = new DeleteConstraintExpression(ConstraintType.Unique);

            expression.Constraint.TableName      = TestTableName1;
            expression.Constraint.ConstraintName = "TESTUNIQUECONSTRAINT";
            return(expression);
        }
Esempio n. 8
0
        public void WhenDefaultSchemaConventionIsChangedAndSchemaIsNotSetThenSetSchema()
        {
            var expression = new DeleteConstraintExpression(ConstraintType.Unique);

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

            Assert.That(processed.Constraint.SchemaName, Is.EqualTo("testdefault"));
        }
Esempio n. 9
0
        public void WhenDefaultSchemaConventionIsAppliedAndSchemaIsNotSetThenSchemaShouldBeNull()
        {
            var expression = new DeleteConstraintExpression(ConstraintType.Unique);

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

            Assert.That(processed.Constraint.SchemaName, Is.Null);
        }
Esempio n. 10
0
        /// <inheritdoc />
        public IDeleteConstraintBuilder UniqueConstraint(string constraintName)
        {
            var expression = new DeleteConstraintExpression(_context, ConstraintType.Unique)
            {
                Constraint = { ConstraintName = constraintName }
            };

            return(new DeleteConstraintBuilder(expression));
        }
        public override string Generate(DeleteConstraintExpression expression)
        {
            var withParts = GetWithOptions(expression);
            var withPart  = !string.IsNullOrEmpty(withParts)
                ? $" WITH ({withParts})"
                : string.Empty;

            return($"{base.Generate(expression)}{withPart}");
        }
Esempio n. 12
0
        public override string Generate(DeleteConstraintExpression expression)
        {
            if (expression.Constraint.IsPrimaryKeyConstraint)
            {
                return(string.Format("ALTER TABLE {0} DROP PRIMARY KEY;", Quoter.QuoteTableName(expression.Constraint.TableName)));
            }

            return(string.Format("{0};", base.Generate(expression)));
        }
Esempio n. 13
0
        /// <inheritdoc />
        public IDeleteConstraintBuilder PrimaryKey(string primaryKeyName)
        {
            var expression = new DeleteConstraintExpression(_context, ConstraintType.PrimaryKey)
            {
                Constraint = { ConstraintName = primaryKeyName }
            };

            return(new DeleteConstraintBuilder(expression));
        }
Esempio n. 14
0
        public IDeleteConstraintOnTableSyntax UniqueConstraint(string constraintName)
        {
            var expression = new DeleteConstraintExpression(ConstraintType.Unique)
            {
                Constraint = { ConstraintName = constraintName }
            };

            _context.Expressions.Add(expression);
            return(new DeleteConstraintBuilder(expression));
        }
        public IDeleteConstraintOnTableSyntax PrimaryKey(string primaryKeyName)
        {
            var expression = new DeleteConstraintExpression(_context.CurrentDatabaseProvider, _databaseProviders, _sqlSyntax, ConstraintType.PrimaryKey)
            {
                Constraint = { ConstraintName = primaryKeyName }
            };

            _context.Expressions.Add(expression);
            return(new DeleteConstraintBuilder(expression));
        }
Esempio n. 16
0
        public void ErrorIsNotReturnedWhenTableNameIsNotNullEmptyString()
        {
            var expression = new DeleteConstraintExpression(ConstraintType.Unique)
            {
                Constraint = { TableName = "aTable" }
            };
            var errors = ValidationHelper.CollectErrors(expression);

            errors.ShouldNotContain(ErrorMessages.TableNameCannotBeNullOrEmpty);
        }
        public void CanDeleteConstraint()
        {
            var expression = new DeleteConstraintExpression(ConstraintType.Unique);

            expression.Constraint.TableName      = "ConstraintTable";
            expression.Constraint.ConstraintName = "Constraint";

            string sql = generator.Generate(expression);

            sql.ShouldBe("ALTER TABLE \"public\".\"ConstraintTable\" DROP CONSTRAINT \"Constraint\"");
        }
Esempio n. 18
0
        public void ApplyDefaultContraintName()
        {
            var expression = new DeleteConstraintExpression(ConstraintType.Unique);
            var builder    = new DeleteConstraintExpressionBuilder(expression);

            builder.FromTable("Users").Column("AccountId");

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

            Assert.That(processed.Constraint.ConstraintName, Is.EqualTo("UC_Users_AccountId"));
        }
Esempio n. 19
0
        public void WhenDefaultSchemaConventionIsAppliedAndSchemaIsSetThenSchemaShouldNotBeChanged()
        {
            var expression = new DeleteConstraintExpression(ConstraintType.Unique)
            {
                Constraint =
                {
                    SchemaName = "testschema",
                },
            };

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

            Assert.That(processed.Constraint.SchemaName, Is.EqualTo("testschema"));
        }
Esempio n. 20
0
        public override string Generate(DeleteConstraintExpression expression)
        {
            if (!expression.Constraint.IsUniqueConstraint)
            {
                return(CompatibilityMode.HandleCompatibilty("Only UNIQUE constraints are supported in SQLite"));
            }

            // Convert the constraint into a drop UNIQUE index
            var idx = new DeleteIndexExpression();

            idx.Index.Name       = expression.Constraint.ConstraintName;
            idx.Index.SchemaName = expression.Constraint.SchemaName;

            return(Generate(idx));
        }
Esempio n. 21
0
        private IEnumerable <DifferentialExpression> GetAlters(CreateConstraintExpression from, CreateConstraintExpression to)
        {
            var deleteOld = new DeleteConstraintExpression(ConstraintType.PrimaryKey)
            {
                Constraint = from.Constraint
            };
            var createNew = to;

            var deleteNew = new DeleteConstraintExpression(ConstraintType.PrimaryKey)
            {
                Constraint = to.Constraint
            };
            var createOld = from;

            return(new DifferentialExpression[]
            {
                new DifferentialExpression(deleteOld, createOld),
                new DifferentialExpression(createNew, deleteNew)
            });
        }
Esempio n. 22
0
 public override string Generate(DeleteConstraintExpression expression)
 {
     Truncator.Truncate(expression);
     return(base.Generate(expression));
 }
Esempio n. 23
0
 public virtual void Process(DeleteConstraintExpression expression)
 {
     Process(Generator.Generate(expression));
 }
Esempio n. 24
0
 public override string Generate(DeleteConstraintExpression expression)
 {
     return(string.Format("ALTER TABLE {0}.{1}", Quoter.QuoteSchemaName(expression.Constraint.SchemaName), base.Generate(expression)));
 }
Esempio n. 25
0
 public override string Generate(DeleteConstraintExpression expression)
 {
     return(CompatibilityMode.HandleCompatibilty("Constraints are not supported"));
 }
Esempio n. 26
0
 public override void Process(DeleteConstraintExpression expression)
 {
     truncator.Truncate(expression);
     RegisterExpression(expression, typeof(DeleteConstraintExpression));
     InternalProcess(Generator.Generate(expression));
 }
Esempio n. 27
0
 public abstract string Generate(DeleteConstraintExpression expression);
Esempio n. 28
0
 public override string Generate(DeleteConstraintExpression expression)
 {
     return(string.Format(DeleteConstraint,
                          Quoter.QuoteTableName(expression.Constraint.TableName, expression.Constraint.SchemaName),
                          Quoter.QuoteConstraintName(expression.Constraint.ConstraintName)));
 }
Esempio n. 29
0
 public override string Generate(DeleteConstraintExpression expression)
 {
     return(string.Format(DeleteConstraint, Quoter.QuoteTableName(expression.Constraint.TableName), Quoter.Quote(expression.Constraint.ConstraintName), CommandDelimiter));
 }
 public override void Process(DeleteConstraintExpression expression)
 {
     Truncator.Truncate(expression);
     InternalProcess(Generator.Generate(expression));
 }
Esempio n. 31
0
 public void Truncate(DeleteConstraintExpression expression)
 {
     Truncate(expression.Constraint);
 }