How do I get a constraint's default name as generated using MetaData's naming convention? I'm dynamically creating a constraint, and then looking it up, but to look it up I need its name. I need to identify the constraint uniquely, without giving it a user-specified name.
I tried appending it to an SQLALchemy Table with Table.append_constraint, but even so its name field is None. I expect it to have a name generated according to the naming convention. Example:
naming_convention = {
"uq": '%(table_name)s_%(column_0_name)s_uq'
}
metadata = MetaData(naming_convention = naming_convention)
table = Table("table1", metadata, Column('col1', Integer))
constraint = UniqueConstraint('col1', name = None)
table.append_constraint(constraint)
default_constraint_name = constraint.name
default_constraint_name == 'table1_col1s_uq'
# False
default_constraint_name == None
# True