MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / visit_drop_constraint

Method visit_drop_constraint

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

Source from the content-addressed store, hash-verified

7084 return text + self.preparer.format_sequence(drop.element)
7085
7086 def visit_drop_constraint(self, drop, **kw):
7087 constraint = drop.element
7088 if constraint.name is not None:
7089 formatted_name = self.preparer.format_constraint(constraint)
7090 else:
7091 formatted_name = None
7092
7093 if formatted_name is None:
7094 raise exc.CompileError(
7095 "Can't emit DROP CONSTRAINT for constraint %r; "
7096 "it has no name" % drop.element
7097 )
7098 return "ALTER TABLE %s DROP CONSTRAINT %s%s%s" % (
7099 self.preparer.format_table(drop.element.table),
7100 "IF EXISTS " if drop.if_exists else "",
7101 formatted_name,
7102 " CASCADE" if drop.cascade else "",
7103 )
7104
7105 def get_column_specification(self, column, **kwargs):
7106 colspec = (

Callers

nothing calls this directly

Calls 2

format_constraintMethod · 0.80
format_tableMethod · 0.80

Tested by

no test coverage detected