#17000: sql/query.py add_q refactoring
-------------------------------------+-------------------------------------
     Reporter:  akaariai             |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |                  Version:  1.3
    Component:  Database layer       |               Resolution:
  (models, ORM)                      |             Triage Stage:  Design
     Severity:  Normal               |  decision needed
     Keywords:                       |      Needs documentation:  0
    Has patch:  1                    |  Patch needs improvement:  0
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by akaariai):

 Actually, the correct approach might not be to defer the where/having
 splitting to execution stage. Maybe it is to have an additional preprocess
 stage before add_q instead.

 The problem is that currently we are going into the q-objects blind. This
 causes multiple issues: We might stumble upon aggregates (at which point
 we must have the path information available to produce correctly negated
 having tree), or we might stumble upon multi-joins (we use the except
 `MultiJoin` in this case currently, and this isn't the cleanest of
 approaches), or we might stumble upon filters that produce additional
 filters (extra_filters, and the need to keep a fresh AND node constantly
 at hand for this possibility, and the mutual recursion between
 setup_joins() and add_filter()).

 If we pre-processed the q-objects (travelled the lookup paths in the
 q-objects, and checked what there is to expect) then the add_q
 where/having logic would be much easier to refactor, the `MultiJoin` case
 would be cleaner, and the extra_filters would be trivial to handle. The
 benefits seem clear. Of course, without actual code many ideas seem
 great... I definitely think this approach is worth investigating a lot
 closer before proceeding further in this ticket. The start is to handle
 the where/having split. The checking for extra_filters and MultiJoin needs
 much larger changes.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17000#comment:5>
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to