#35373: GeneratedField alteration fail on SQLite due table remake data insertion -------------------------------------+------------------------------------- Reporter: Moshe Dicker | Owner: nobody Type: Bug | Status: new Component: Database layer | Version: 5.0 (models, ORM) | Severity: Release blocker | Resolution: Keywords: migrations,db | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by Simon Charette):
* easy: 1 => 0 * severity: Normal => Release blocker * stage: Unreviewed => Accepted * summary: db_index=True on a Generated Column generates failing migrations => GeneratedField alteration fail on SQLite due table remake data insertion Comment: Thank you for your report, a traceback and a description of the backend you are using would have been appreciated. This looks like a problem isolated to SQLite due to the way `_remake_table` doesn't exclude generated fields from its `INSERT INTO new_table SELECT ... FROM old_table` at table rename (a necessary step since SQLite doesn't support most table operations). {{{#!diff diff --git a/django/db/backends/sqlite3/schema.py b/django/db/backends/sqlite3/schema.py index 495714a894..32f4f08459 100644 --- a/django/db/backends/sqlite3/schema.py +++ b/django/db/backends/sqlite3/schema.py @@ -150,7 +150,9 @@ def is_self_referential(f): body.pop(old_field.name, None) mapping.pop(old_field.column, None) body[new_field.name] = new_field - if old_field.null and not new_field.null: + if new_field.generated: + pass + elif 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)) else: }}} -- Ticket URL: <https://code.djangoproject.com/ticket/35373#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/0107018edb034b8f-2a24d876-fbd9-4b5c-af15-8ffc5dc36988-000000%40eu-central-1.amazonses.com.