MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _constraint_name

Function _constraint_name

lib/sqlalchemy/sql/naming.py:190–209  ·  view source on GitHub ↗
(const, table)

Source from the content-addressed store, hash-verified

188@event.listens_for(Constraint, "after_parent_attach")
189@event.listens_for(Index, "after_parent_attach")
190def _constraint_name(const, table):
191 if isinstance(table, Column):
192 # this path occurs for a CheckConstraint linked to a Column
193
194 # for column-attached constraint, set another event
195 # to link the column attached to the table as this constraint
196 # associated with the table.
197 event.listen(
198 table,
199 "after_parent_attach",
200 lambda col, table: _constraint_name(const, table),
201 )
202
203 elif isinstance(table, Table):
204 if isinstance(const.name, conv) or const.name is _NONE_NAME:
205 return
206
207 newname = _constraint_name_for_table(const, table)
208 if newname:
209 const.name = newname

Callers

nothing calls this directly

Calls 2

listenMethod · 0.45

Tested by

no test coverage detected