diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-06-02 19:37:25 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-06-02 19:37:25 -0400 |
commit | 474088e9403fcfc444f114e3948aa77f6f262caf (patch) | |
tree | f9f10492277e67b3fbebff657840c37a968e60a4 /tests/test_op.py | |
parent | 9daaaf82e0895a54883609ea0777563929b2ae3b (diff) | |
download | alembic-474088e9403fcfc444f114e3948aa77f6f262caf.tar.gz |
Set create_constraint=True for Enum / Boolean tests
In SQLAlchemy [1] [2] we are changing the default
for Enum / Boolean create_constraint to False. ensure
tests that rely upon this setting being True set
it explicitly.
[1] I0a3fb608ce32143fa757546cc17ba2013e93272a
[2] https://github.com/sqlalchemy/sqlalchemy/issues/5367
Change-Id: Ic823124446607c2f245663350632382bd1ca10ba
Diffstat (limited to 'tests/test_op.py')
-rw-r--r-- | tests/test_op.py | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/tests/test_op.py b/tests/test_op.py index 98daa5f..1406dbd 100644 --- a/tests/test_op.py +++ b/tests/test_op.py @@ -181,7 +181,9 @@ class OpTest(TestBase): def test_add_column_schema_type(self): """Test that a schema type generates its constraints....""" context = op_fixture() - op.add_column("t1", Column("c1", Boolean, nullable=False)) + op.add_column( + "t1", Column("c1", Boolean(create_constraint=True), nullable=False) + ) context.assert_( "ALTER TABLE t1 ADD COLUMN c1 BOOLEAN NOT NULL", "ALTER TABLE t1 ADD CHECK (c1 IN (0, 1))", @@ -191,7 +193,9 @@ class OpTest(TestBase): """Test that a schema type generates its constraints....""" context = op_fixture() op.add_column( - "t1", Column("c1", Boolean, nullable=False), schema="foo" + "t1", + Column("c1", Boolean(create_constraint=True), nullable=False), + schema="foo", ) context.assert_( "ALTER TABLE foo.t1 ADD COLUMN c1 BOOLEAN NOT NULL", @@ -202,7 +206,9 @@ class OpTest(TestBase): """Test that a schema type doesn't generate a constraint based on check rule.""" context = op_fixture("postgresql") - op.add_column("t1", Column("c1", Boolean, nullable=False)) + op.add_column( + "t1", Column("c1", Boolean(create_constraint=True), nullable=False) + ) context.assert_("ALTER TABLE t1 ADD COLUMN c1 BOOLEAN NOT NULL") def test_add_column_fk_self_referential(self): @@ -390,7 +396,7 @@ class OpTest(TestBase): def test_alter_column_schema_type_unnamed(self): context = op_fixture("mssql", native_boolean=False) - op.alter_column("t", "c", type_=Boolean()) + op.alter_column("t", "c", type_=Boolean(create_constraint=True)) context.assert_( "ALTER TABLE t ALTER COLUMN c BIT", "ALTER TABLE t ADD CHECK (c IN (0, 1))", @@ -398,7 +404,9 @@ class OpTest(TestBase): def test_alter_column_schema_schema_type_unnamed(self): context = op_fixture("mssql", native_boolean=False) - op.alter_column("t", "c", type_=Boolean(), schema="foo") + op.alter_column( + "t", "c", type_=Boolean(create_constraint=True), schema="foo" + ) context.assert_( "ALTER TABLE foo.t ALTER COLUMN c BIT", "ALTER TABLE foo.t ADD CHECK (c IN (0, 1))", @@ -406,7 +414,9 @@ class OpTest(TestBase): def test_alter_column_schema_type_named(self): context = op_fixture("mssql", native_boolean=False) - op.alter_column("t", "c", type_=Boolean(name="xyz")) + op.alter_column( + "t", "c", type_=Boolean(name="xyz", create_constraint=True) + ) context.assert_( "ALTER TABLE t ALTER COLUMN c BIT", "ALTER TABLE t ADD CONSTRAINT xyz CHECK (c IN (0, 1))", @@ -414,7 +424,12 @@ class OpTest(TestBase): def test_alter_column_schema_schema_type_named(self): context = op_fixture("mssql", native_boolean=False) - op.alter_column("t", "c", type_=Boolean(name="xyz"), schema="foo") + op.alter_column( + "t", + "c", + type_=Boolean(name="xyz", create_constraint=True), + schema="foo", + ) context.assert_( "ALTER TABLE foo.t ALTER COLUMN c BIT", "ALTER TABLE foo.t ADD CONSTRAINT xyz CHECK (c IN (0, 1))", @@ -423,7 +438,10 @@ class OpTest(TestBase): def test_alter_column_schema_type_existing_type(self): context = op_fixture("mssql", native_boolean=False) op.alter_column( - "t", "c", type_=String(10), existing_type=Boolean(name="xyz") + "t", + "c", + type_=String(10), + existing_type=Boolean(name="xyz", create_constraint=True), ) context.assert_( "ALTER TABLE t DROP CONSTRAINT xyz", @@ -436,7 +454,7 @@ class OpTest(TestBase): "t", "c", type_=String(10), - existing_type=Boolean(name="xyz"), + existing_type=Boolean(name="xyz", create_constraint=True), schema="foo", ) context.assert_( |