MCPcopy
hub / github.com/django/django / add_field

Method add_field

django/db/backends/mysql/schema.py:86–100  ·  view source on GitHub ↗
(self, model, field)

Source from the content-addressed store, hash-verified

84 return super()._column_default_sql(field)
85
86 def add_field(self, model, field):
87 super().add_field(model, field)
88
89 # Simulate the effect of a one-off default.
90 # field.default may be unhashable, so a set isn't used for "in" check.
91 if self.skip_default(field) and field.default not in (None, NOT_PROVIDED):
92 effective_default = self.effective_default(field)
93 self.execute(
94 "UPDATE %(table)s SET %(column)s = %%s"
95 % {
96 "table": self.quote_name(model._meta.db_table),
97 "column": self.quote_name(field.column),
98 },
99 [effective_default],
100 )
101
102 def remove_constraint(self, model, constraint):
103 if (

Callers 1

Calls 4

skip_defaultMethod · 0.95
executeMethod · 0.95
effective_defaultMethod · 0.80
quote_nameMethod · 0.45

Tested by

no test coverage detected