8000 Fixed 36350 -- Respected Field.db_check() when deciding whether to re… · django/django@d5c2e92 · GitHub
[go: up one dir, main page]

Skip to content

Commit d5c2e92

Browse files
committed
Fixed 36350 -- Respected Field.db_check() when deciding whether to recreate constraint
This is a regression introduced by 9953c80
1 parent 4e04c2e commit d5c2e92

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

django/db/backends/base/schema.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -923,13 +923,11 @@ def alter_field(self, model, old_field, new_field, strict=False):
923923
def _field_db_check(self, field, field_db_params):
924924
# Always check constraints with the same mocked column name to avoid
925925
# recreating constrains when the column is renamed.
926-
check_constraints = self.connection.data_type_check_constraints
926+
if (constraint := field.db_check(self.connection)) is None:
927+
return None
927928
data = field.db_type_parameters(self.connection)
928929
data["column"] = "__column_name__"
929-
try:
930-
return check_constraints[field.get_internal_type()] % data
931-
except KeyError:
932-
return None
930+
return constraint % data
933931

934932
def _alter_field(
935933
self,

0 commit comments

Comments
 (0)
0