diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-04-19 12:31:19 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-04-19 12:31:19 -0400 |
commit | c33d0378802abbc729de55ba205a4309e5d68f6b (patch) | |
tree | 1e8994db447e9908827c6494db8d0241a7a6de52 /lib/sqlalchemy/sql/naming.py | |
parent | 1fb4ad75a38ce84d0e7b170927025500b73b5519 (diff) | |
download | sqlalchemy-c33d0378802abbc729de55ba205a4309e5d68f6b.tar.gz |
- 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
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 |