1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #35373 -- Fixed a crash when indexing a generated field on SQLite.

Generated fields have to be excluded from the INSERT query against the remade
table including the index.

Thanks Moshe Dicker for the report, David Sanders and Mariusz Felisiak for the
review.
This commit is contained in:
Simon Charette
2024-04-16 00:11:36 -04:00
committed by Sarah Boyce
parent 47c608202a
commit d048f0d311
3 changed files with 40 additions and 1 deletions

View File

@@ -150,6 +150,9 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
body.pop(old_field.name, None)
mapping.pop(old_field.column, None)
body[new_field.name] = new_field
rename_mapping[old_field.name] = new_field.name
if new_field.generated:
continue
if old_field.null and not new_field.null:
if new_field.db_default is NOT_PROVIDED:
default = self.prepare_default(self.effective_default(new_field))
@@ -162,7 +165,6 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
mapping[new_field.column] = case_sql
else:
mapping[new_field.column] = self.quote_name(old_field.column)
rename_mapping[old_field.name] = new_field.name
# Remove any deleted fields
if delete_field:
del body[delete_field.name]