From d85d6f9a3f1d3132abcd917d4378b2c4e14aec65 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 12 Mar 2014 14:46:55 -0400 Subject: - Fixed bug in new :paramref:`.MetaData.naming_convention` feature where the name of a check constraint making use of the `"%(constraint_name)s"` token would get doubled up for the constraint generated by a boolean or enum type, and overall duplicate events would cause the `"%(constraint_name)s"` token to keep compounding itself. fixes #2991 --- lib/sqlalchemy/sql/naming.py | 2 +- lib/sqlalchemy/sql/sqltypes.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/naming.py b/lib/sqlalchemy/sql/naming.py index ee99ccbce..bbb843121 100644 --- a/lib/sqlalchemy/sql/naming.py +++ b/lib/sqlalchemy/sql/naming.py @@ -22,7 +22,7 @@ class ConventionDict(object): self._is_fk = isinstance(const, ForeignKeyConstraint) self.table = table self.convention = convention - self._const_name = const.name + self._const_name = const._orig_name = getattr(const, '_orig_name', const.name) def _key_table_name(self): return self.table.name diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index fee424e65..ec1d66459 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -1131,7 +1131,7 @@ class Enum(String, SchemaType): _create_rule=util.portable_instancemethod( self._should_create_constraint) ) - table.append_constraint(e) + assert e.table is table def adapt(self, impltype, **kw): schema = kw.pop('schema', self.schema) @@ -1268,7 +1268,7 @@ class Boolean(TypeEngine, SchemaType): _create_rule=util.portable_instancemethod( self._should_create_constraint) ) - table.append_constraint(e) + assert e.table is table @property def python_type(self): -- cgit v1.2.1