#34964: Reversing the order of Q objects in a CheckConstraint generates a 
migration
-------------------------------------+-------------------------------------
     Reporter:  Jacob Walls          |                    Owner:  Jacob
         Type:                       |  Walls
  Cleanup/optimization               |                   Status:  assigned
    Component:  Migrations           |                  Version:  dev
     Severity:  Normal               |               Resolution:
     Keywords:  noop                 |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Jacob Walls):

 Thanks for the extra context around those edge cases. I'd love to know
 more about them so I can look for them in my own projects.

 I notice we've been sorting the arguments to the Q constructor since
 #29125. So if someone did need to change the order to work around a
 database edge case, they'd ''want'' a change from `Q(A, B)` to `Q(A) &
 Q(B)` to generate a migration, since if B sorts before A, it can only be
 expressed in Django as the latter, and this PR would take away the
 migration to make it.

 The argument in favor of this change (which is very slight, I know) is
 that refactoring the code for consistency/readability with the surrounding
 constraints might generate a migration with a table rebuild. That's
 something you might miss. In other words, you need to know that it's not
 worth paying that cost when you're editing/reviewing the code. Until I
 knew about these edge cases, I thought that was a potential DX win to
 reduce cognitive burden.

 Finally, I guess if we still wanted this change we might ought to block it
 on a resolution of #25245. Should we Someday/Maybe this ticket, then?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34964#comment:9>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018bc9007dd9-d21600f1-671b-4c72-a539-6fa428595e51-000000%40eu-central-1.amazonses.com.

Reply via email to