1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Refs #35149 -- Made equivalent db_default alterations noops.

This allows for an easier transition of preserving the literal nature of
non-compilable db_default.
This commit is contained in:
Simon Charette
2024-02-03 01:10:41 -05:00
committed by Mariusz Felisiak
parent dfc77637ea
commit fe1cb62f5c
2 changed files with 25 additions and 0 deletions

View File

@@ -1640,6 +1640,14 @@ class BaseDatabaseSchemaEditor:
):
old_kwargs.pop("to", None)
new_kwargs.pop("to", None)
# db_default can take many form but result in the same SQL.
if (
old_kwargs.get("db_default")
and new_kwargs.get("db_default")
and self.db_default_sql(old_field) == self.db_default_sql(new_field)
):
old_kwargs.pop("db_default")
new_kwargs.pop("db_default")
return self.quote_name(old_field.column) != self.quote_name(
new_field.column
) or (old_path, old_args, old_kwargs) != (new_path, new_args, new_kwargs)