summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-01-30 13:38:51 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2015-01-30 13:38:51 -0500
commit383bb3f708168aedb1832050a84ff054f8211386 (patch)
tree3bc8837150ab66a2be63c780ac5912f5cb89e5bc /test/sql
parent3712e35c329cc3b5106f026be90e04f65412586d (diff)
downloadsqlalchemy-383bb3f708168aedb1832050a84ff054f8211386.tar.gz
- 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
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_constraints.py2
-rw-r--r--test/sql/test_metadata.py21
2 files changed, 22 insertions, 1 deletions
diff --git a/test/sql/test_constraints.py b/test/sql/test_constraints.py
index 2603f67a3..eb558fc95 100644
--- a/test/sql/test_constraints.py
+++ b/test/sql/test_constraints.py
@@ -1063,7 +1063,7 @@ class ConstraintAPITest(fixtures.TestBase):
)
assert_raises_message(
exc.ArgumentError,
- "Column 't2.y' is not part of table 't1'.",
+ r"Column\(s\) 't2.y' are not part of table 't1'.",
Index,
"bar", t1.c.x, t2.c.y
)
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"})