diff options
Diffstat (limited to 'lib/sqlalchemy/sql/naming.py')
-rw-r--r-- | lib/sqlalchemy/sql/naming.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/sqlalchemy/sql/naming.py b/lib/sqlalchemy/sql/naming.py index 1c5fae193..34a72a011 100644 --- a/lib/sqlalchemy/sql/naming.py +++ b/lib/sqlalchemy/sql/naming.py @@ -158,8 +158,9 @@ def _constraint_name(const, table): metadata = table.metadata convention = _get_convention(metadata.naming_convention, type(const)) if convention is not None: - newname = conv( - convention % ConventionDict(const, table, metadata.naming_convention) - ) - if const.name is None: - const.name = newname + if const.name is None or "constraint_name" in convention: + newname = conv( + convention % ConventionDict(const, table, metadata.naming_convention) + ) + if const.name is None: + const.name = newname |