#18748: Remove dupe-avoidance logic from the ORM
-------------------------------------+-------------------------------------
     Reporter:  akaariai             |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |                  Version:  master
    Component:  Database layer       |               Resolution:
  (models, ORM)                      |             Triage Stage:  Ready for
     Severity:  Normal               |  checkin
     Keywords:                       |      Needs documentation:  0
    Has patch:  1                    |  Patch needs improvement:  0
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by akaariai):

 OK, I now know what exclude was used for - when combining queries and the
 rhs query has two joins for the same connection we must exclude the alias
 used for the first connection. As an example:
 {{{
 q1 = qs.filter(m2m__f=1)
 q2 = qs.filter(m2m__f=1).filter(m2m__f=2)
 }}}
 Now, we have two joins for m2m in q2, and specifically they have the same
 connections for the m2m joins. If we do (q1|q2), then we will reuse all
 joins for the first m2m join. If we don't exclude the alias used for the
 first m2m join, then we will again reuse the same join for the second m2m
 join. This would result in having just one join in the combined query.
 This is wrong, as the original rhs query had two joins.

 I have done a fix for this in the
 https://github.com/akaariai/django/compare/dupe_away, specifically in
 
https://github.com/akaariai/django/commit/da96154a72c4c4ca53cce198a82bb6af3f87ff64
 - note that the exclude arg is still gone, instead I use the reuse arg
 here.

 I also reworked the .join() implementation
 
(https://github.com/akaariai/django/commit/b42280f45c7cd0fcde835ee4665e9d67327fda1d).
 I feel the code is much improved, but I can't claim to understand the
 existing code in full. I am afraid that there are other regressions
 lurking...

 If anybody can review this I would much appreciate it!

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18748#comment:8>
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 https://groups.google.com/groups/opt_out.


Reply via email to