From 383bb3f708168aedb1832050a84ff054f8211386 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 30 Jan 2015 13:38:51 -0500 Subject: - The :class:`.CheckConstraint` construct now supports naming conventions that include the token ``%(column_0_name)s``; the constraint expression is scanned for columns. Additionally, naming conventions for check constraints that don't include the ``%(constraint_name)s`` token will now work for :class:`.SchemaType`- generated constraints, such as those of :class:`.Boolean` and :class:`.Enum`; this stopped working in 0.9.7 due to :ticket:`3067`. fixes #3299 --- test/sql/test_metadata.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test/sql/test_metadata.py') diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py index 206f4bd16..1eec502e7 100644 --- a/test/sql/test_metadata.py +++ b/test/sql/test_metadata.py @@ -3441,6 +3441,27 @@ class NamingConventionTest(fixtures.TestBase, AssertsCompiledSQL): ")" ) + def test_schematype_ck_name_boolean_not_on_name(self): + m1 = MetaData(naming_convention={ + "ck": "ck_%(table_name)s_%(column_0_name)s"}) + + u1 = Table('user', m1, + Column('x', Boolean()) + ) + # constraint is not hit + eq_( + [c for c in u1.constraints + if isinstance(c, CheckConstraint)][0].name, "_unnamed_" + ) + # but is hit at compile time + self.assert_compile( + schema.CreateTable(u1), + 'CREATE TABLE "user" (' + "x BOOLEAN, " + "CONSTRAINT ck_user_x CHECK (x IN (0, 1))" + ")" + ) + def test_schematype_ck_name_enum(self): m1 = MetaData(naming_convention={ "ck": "ck_%(table_name)s_%(constraint_name)s"}) -- cgit v1.2.1