From 97cd0a5db8bb2e47f38899592740d1bc75ec0412 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 2 Jun 2020 14:21:03 -0400 Subject: Default create_constraint to False The :paramref:`.Enum.create_constraint` and :paramref:`.Boolean.create_constraint` parameters now default to False, indicating when a so-called "non-native" version of these two datatypes is created, a CHECK constraint will not be generated by default. These CHECK constraints present schema-management maintenance complexities that should be opted in to, rather than being turned on by default. Fixes: #5367 Change-Id: I0a3fb608ce32143fa757546cc17ba2013e93272a --- test/dialect/postgresql/test_compiler.py | 5 ++++- test/dialect/postgresql/test_types.py | 36 ++++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 5 deletions(-) (limited to 'test/dialect/postgresql') diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index c707137a8..2223b0a76 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -212,7 +212,10 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): t1 = Table( "sometable", MetaData(), - Column("somecolumn", Enum("x", "y", "z", native_enum=False)), + Column( + "somecolumn", + Enum("x", "y", "z", native_enum=False, create_constraint=True), + ), ) self.assert_compile( schema.CreateTable(t1), diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py index 2adde8edc..d7f6faf92 100644 --- a/test/dialect/postgresql/test_types.py +++ b/test/dialect/postgresql/test_types.py @@ -288,7 +288,14 @@ class EnumTest(fixtures.TestBase, AssertsExecutionResults): metadata, Column( "bar", - Enum("one", "two", "three", name="myenum", native_enum=False), + Enum( + "one", + "two", + "three", + name="myenum", + create_constraint=True, + native_enum=False, + ), ), ) @@ -317,7 +324,14 @@ class EnumTest(fixtures.TestBase, AssertsExecutionResults): "foo", metadata, Column( - "bar", Enum("B", util.u("Ü"), name="myenum", native_enum=False) + "bar", + Enum( + "B", + util.u("Ü"), + name="myenum", + create_constraint=True, + native_enum=False, + ), ), ) @@ -500,7 +514,16 @@ class EnumTest(fixtures.TestBase, AssertsExecutionResults): t1 = Table( "foo", metadata, - Column("bar", Enum("one", "two", "three", name="myenum")), + Column( + "bar", + Enum( + "one", + "two", + "three", + name="myenum", + create_constraint=True, + ), + ), ) def go(): @@ -1762,7 +1785,12 @@ class ArrayEnum(fixtures.TestBase): "my_col", array_cls( enum_cls( - "foo", "bar", "baz", name="my_enum", native_enum=False + "foo", + "bar", + "baz", + name="my_enum", + create_constraint=True, + native_enum=False, ) ), ), -- cgit v1.2.1