From 506b88de5e428fd4ad2feff663ba53e2dbb28891 Mon Sep 17 00:00:00 2001 From: Gord Thompson Date: Sat, 6 Mar 2021 12:19:13 -0700 Subject: Fix named CHECK constraint name omitted on repeated creates Fixed issue where the CHECK constraint generated by :class:`_types.Boolean` or :class:`_types.Enum` would fail to render the naming convention correctly after the first compilation, due to an unintended change of state within the name given to the constraint. This issue was first introduced in 0.9 in the fix for issue #3067, and the fix revises the approach taken at that time which appears to have been more involved than what was needed. Co-authored-by: Mike Bayer Fixes: #6007 Change-Id: I7ecff0a9d86191520f6841b3922a5af5a6971fba --- lib/sqlalchemy/sql/compiler.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'lib/sqlalchemy/sql/compiler.py') diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index c6fa6072e..d48bca14e 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -4902,16 +4902,13 @@ class IdentifierPreparer(object): def format_constraint(self, constraint, _alembic_quote=True): naming = util.preloaded.sql_naming - if isinstance(constraint.name, elements._defer_name): + if constraint.name is elements._NONE_NAME: name = naming._constraint_name_for_table( constraint, constraint.table ) if name is None: - if isinstance(constraint.name, elements._defer_none_name): - return None - else: - name = constraint.name + return None else: name = constraint.name -- cgit v1.2.1