Opened 6 years ago

Closed 6 years ago

Last modified 4 years ago

#29838 closed Bug (fixed)

Hashing list in Q objects when using __in lookup

Reported by: Andrew Owned by: Andrew
Component: Utilities Version: 2.0
Severity: Release blocker Keywords: hash, tuple, list
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

This bug was previously reported here - #29643.

However I am still getting this error upon rendering QuerySets that use the Q object and include the __in filter in the most recent release of django, 2.1.2.

Here is my reproduction of the bug on master:

Code highlighting:

>>> q = Q(a__in=[1, 2])
>>> q.__hash__()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/aspalding/Documents/django/django/utils/tree.py", line 89, in __hash__
    for child in self.children
TypeError: unhashable type: 'list'

Therefor the minimal reproduction for NodeTest would look like:

Code highlighting:

hash(Node([('a', [1, 2])]))

Change History (6)

comment:2 by Tim Graham, 6 years ago

Patch needs improvement: set
Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted
Version: master2.0

It qualifies for a backport to stable/2.1.x since it's a regression in 508b5debfb16843a8443ebac82c1fb91f15da687.

comment:3 by Tim Graham <timograham@…>, 6 years ago

In 217f82d7:

Refs #29838 -- Fixed make_hashable() for values that have lists or dicts nested in tuples.

And for non-hashable values that are iterable, e.g. sets.

comment:4 by Tim Graham <timograham@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In dc5e75d4:

Fixed #29838 -- Fixed crash when combining Q objects with in lookups and lists.

Regression in fc6528b25ab1834be1a478b405bf8f7ec5cf860c.

comment:5 by Tim Graham <timograham@…>, 6 years ago

In 0df7ea1:

[2.1.x] Fixed #29838 -- Fixed crash when combining Q objects with in lookups and lists.

Regression in fc6528b25ab1834be1a478b405bf8f7ec5cf860c.

Backport of 834c4ec8e4cfc43acf0525e0a4d8c914534f6afd,
217f82d7139fd32f07adbfa92c5fb383d0ade577, and
dc5e75d419893bde33b7e439b59bdf271fc1a3f2 from master.

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In 4c67552:

Refs #29838, Refs #28507 -- Made make_hashable() ignore key order.

Note: See TracTickets for help on using tickets.
Back to Top