using conv() should be bypassing naming convention entirely
Issue #3068
duplicate
this issue is mostly fixed by c33d0378802a with #3028 but that is a different issue being fixed here. if conv() is present we shouldn't be hitting naming convention logic at all. the below fails in 0.9.4 but succeeds in rel_0_9:
from sqlalchemy import UniqueConstraint, Table, MetaData
from sqlalchemy.sql.naming import conv
m = MetaData(naming_convention={"uq": "uq_%(table_name)s_%(column_0_name)s"})
t = Table('mytable', m)
uq = UniqueConstraint(name=conv('my_special_key'))
t.append_constraint(uq)
Comments (9)
-
reporter -
reporter here's a simple patch:
index 34a72a0..7ac3e96 100644 --- a/lib/sqlalchemy/sql/naming.py +++ b/lib/sqlalchemy/sql/naming.py @@ -158,7 +158,9 @@ def _constraint_name(const, table): metadata = table.metadata convention = _get_convention(metadata.naming_convention, type(const)) if convention is not None: - if const.name is None or "constraint_name" in convention: + if not isinstance(const.name, conv) and ( + const.name is None or "constraint_name" in convention + ): newname = conv( convention % ConventionDict(const, table, metadata.naming_convention) )
-
reporter - marked as critical
-
reporter see also
#3067 -
reporter - changed milestone to 0.9.7
-
reporter - changed status to duplicate
Duplicate of
#3067. -
reporter #3067fixes this so we just need to do that one. -
reporter - changed milestone to 0.9.8
-
reporter - changed milestone to 0.9.7
- Log in to comment
this still fails on latest: