#24424: Removing a model's last field results in SQL syntax error on SQLite
----------------------------+------------------------------------
     Reporter:  adnam       |                    Owner:
         Type:  Bug         |                   Status:  new
    Component:  Migrations  |                  Version:  1.7
     Severity:  Normal      |               Resolution:
     Keywords:              |             Triage Stage:  Accepted
    Has patch:  1           |      Needs documentation:  0
  Needs tests:  0           |  Patch needs improvement:  1
Easy pickings:  0           |                    UI/UX:  0
----------------------------+------------------------------------

Comment (by MarkusH):

 Replying to [comment:21 jwineinger]:
 > When you say "it is not about a DeleteModel operation following a
 RemoveField. That could just remove that field", what do you mean?

 If you have `RemoveField('mymodel', 'myfield')` followed by a
 `DeleteModel('MyModel')` operation, I can't construct a case where Django
 would end up constructing those two operations automatically where the
 `RemoveField` would create a model without fields. A single `DeleteModel`
 operation should be sufficient to drop the table and all its constraints.

 > Should the approach be to change the auto-detector to not produce states
 with zero columns, or should we try and handle that somewhere else?

 Giving this issue more thoughts, I think the only way to prevent the
 autodetector to construct states with models without fields is making the
 `AlterField` operation smarter. Furthermore, when `RemoveField` would drop
 the last field on a model, an `AlterField` operation must be used that
 then can take care of the steps I outlined in [comment:20 comment 20].
 This is only necessary for primary keys, though, I think. All other cases
 can be fixed by first adding the new field and then removing the old
 field.

--
Ticket URL: <https://code.djangoproject.com/ticket/24424#comment:22>
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.c76ddf095d84f9720068b5bf029f5404%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to