From d2193f53c10d29a7a9b1846ebf322fbced55041f Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 14 Jul 2014 20:26:38 -0400 Subject: - Fix bug in naming convention feature where using a check constraint convention that includes ``constraint_name`` would then force all :class:`.Boolean` and :class:`.Enum` types to require names as well, as these implicitly create a constraint, even if the ultimate target backend were one that does not require generation of the constraint such as Postgresql. The mechanics of naming conventions for these particular constraints has been reorganized such that the naming determination is done at DDL compile time, rather than at constraint/table construction time. fixes #3067 --- lib/sqlalchemy/sql/compiler.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/sql/compiler.py') diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 7a8b07f8f..99b74b3c8 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -2902,7 +2902,13 @@ class IdentifierPreparer(object): def format_savepoint(self, savepoint, name=None): return self.quote(name or savepoint.ident) - def format_constraint(self, constraint): + @util.dependencies("sqlalchemy.sql.naming") + def format_constraint(self, naming, constraint): + if isinstance(constraint.name, elements._defer_name): + name = naming._constraint_name_for_table( + constraint, constraint.table) + if name: + return self.quote(name) return self.quote(constraint.name) def format_table(self, table, use_schema=True, name=None): -- cgit v1.2.1