From c33d0378802abbc729de55ba205a4309e5d68f6b Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 19 Apr 2014 12:31:19 -0400 Subject: - Liberalized the contract for :class:`.Index` a bit in that you can specify a :func:`.text` expression as the target; the index no longer needs to have a table-bound column present if the index is to be manually added to the table, either via inline declaration or via :meth:`.Table.append_constraint`. fixes #3028 --- lib/sqlalchemy/sql/naming.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/sqlalchemy/sql/naming.py') 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 -- cgit v1.2.1