MCPcopy
hub / github.com/django/django / constraint_sql

Method constraint_sql

django/contrib/postgres/constraints.py:117–137  ·  view source on GitHub ↗
(self, model, schema_editor)

Source from the content-addressed store, hash-verified

115 return sql % tuple(schema_editor.quote_value(p) for p in params)
116
117 def constraint_sql(self, model, schema_editor):
118 query = Query(model, alias_cols=False)
119 compiler = query.get_compiler(connection=schema_editor.connection)
120 expressions = self._get_expressions(schema_editor, query)
121 table = model._meta.db_table
122 condition = self._get_condition_sql(compiler, schema_editor, query)
123 include = [
124 model._meta.get_field(field_name).column for field_name in self.include
125 ]
126 return Statement(
127 self.template,
128 table=Table(table, schema_editor.quote_name),
129 name=schema_editor.quote_name(self.name),
130 index_type=self.index_type,
131 expressions=Expressions(
132 table, expressions, compiler, schema_editor.quote_value
133 ),
134 where=" WHERE (%s)" % condition if condition else "",
135 include=schema_editor._index_include_sql(model, include),
136 deferrable=schema_editor._deferrable_constraint_sql(self.deferrable),
137 )
138
139 def create_sql(self, model, schema_editor):
140 return Statement(

Callers 1

create_sqlMethod · 0.95

Calls 11

get_compilerMethod · 0.95
_get_expressionsMethod · 0.95
_get_condition_sqlMethod · 0.95
QueryClass · 0.90
StatementClass · 0.90
TableClass · 0.90
ExpressionsClass · 0.90
_index_include_sqlMethod · 0.80
get_fieldMethod · 0.45
quote_nameMethod · 0.45

Tested by

no test coverage detected