MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / visit_drop_constraint

Method visit_drop_constraint

lib/sqlalchemy/sql/compiler.py:7371–7388  ·  view source on GitHub ↗
(self, drop, **kw)

Source from the content-addressed store, hash-verified

7369 return text + self.preparer.format_sequence(drop.element)
7370
7371 def visit_drop_constraint(self, drop, **kw):
7372 constraint = drop.element
7373 if constraint.name is not None:
7374 formatted_name = self.preparer.format_constraint(constraint)
7375 else:
7376 formatted_name = None
7377
7378 if formatted_name is None:
7379 raise exc.CompileError(
7380 "Can't emit DROP CONSTRAINT for constraint %r; "
7381 "it has no name" % drop.element
7382 )
7383 return "ALTER TABLE %s DROP CONSTRAINT %s%s%s" % (
7384 self.preparer.format_table(drop.element.table),
7385 "IF EXISTS " if drop.if_exists else "",
7386 formatted_name,
7387 " CASCADE" if drop.cascade else "",
7388 )
7389
7390 def get_column_specification(
7391 self, column: Column[Any], **kwargs: Any

Callers

nothing calls this directly

Calls 2

format_constraintMethod · 0.80
format_tableMethod · 0.80

Tested by

no test coverage detected