#28297: Same queryset result in two different queries on ORM
-------------------------------------+-------------------------------------
     Reporter:  Marcus Renno         |                    Owner:  Tom
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  1.11
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  join, annotation, F  |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Marcus Renno):

 That seems to be right, Tom. `join()` is relying on the order of the
 dictionary order resulting from `.items()`.

 It's weird that setting the hash seed to 2 would solve this problem,
 though. I feel like the framework should not rely on the user changing the
 hashing seed to a static number to fix this problem, because it breaks the
 purpose (security) of the the hashing being random.

 Replying to [comment:11 Tom]:
 > It seems to boil down to this line:
 
https://github.com/django/django/blob/stable/1.11.x/django/db/models/sql/query.py#L927
 >
 > The `alias_map.items()` isn't stable, with `PYTHONHASHSEED=1` then
 `reuse[0]` is `recepie_steps`, which is incorrect, but with it set to `2`
 then `reuse[0]` is (correctly) `T6`.
 >
 > If anyone knows how to fix this then please let me know, else I will try
 and find a suitable fix.

--
Ticket URL: <https://code.djangoproject.com/ticket/28297#comment:12>
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/069.c3254baf74043e227ba2015c18872b8a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to