#29503 closed Bug (fixed)
Order of parameters pass to __in lookup affected by de-duplication.
Reported by: | Nick Pope | Owned by: | Nick Pope |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.11 |
Severity: | Normal | Keywords: | |
Cc: | Ian Foote, Carlton Gibson | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
After the fix for ticket #25544, the order of parameters passed to the __in
lookup is affected by the de-duplication using set()
.
This results in the generated query being unstable between different runs of the python interpreter due to hash seed randomisation.
Change History (7)
comment:1 by , 7 years ago
Has patch: | set |
---|
follow-up: 3 comment:2 by , 7 years ago
What practical problem did you encounter? I'm surprised that the order of items in an IN
clause would matter much.
comment:3 by , 7 years ago
Replying to Tim Graham:
What practical problem did you encounter? I'm surprised that the order of items in an
IN
clause would matter much.
Heh. I get the feeling that I'm going to get shot down here (and I know and understand the reasons why).
I've inherited some code that currently and for the foreseeable future depends on the output of the query generated by Query.sql_with_params()
.
It executes it via pandas.DataFrame.read_sql_query()
and also uses this to generate a cache key. Because the parameter ordering is unstable, this affects the key generation.
Regardless of the horrors of this, the issue looks like a regression to me - the previous behaviour changed unexpectedly. I can understand if you'd like to only apply this to master, however.
comment:4 by , 7 years ago
Cc: | added |
---|
comment:5 by , 7 years ago
Cc: | added |
---|---|
Triage Stage: | Unreviewed → Ready for checkin |
I'd be happy with the use of OrderedSet
here. Semantically in
uses a set but we (always/mostly?) pass it a list, which is ordered, and it's reasonable enough to maintain that. (Beyond Nick's usage, it could be handy somewhere.)
Is this a regression? Was it always part of the contract? Not sure. Pass. :)
PR