Opened 4 years ago

Closed 4 years ago

#25982 closed New feature (needsinfo)

Djago ORM. Filter using multi-valued queryset

Reported by: Freddie O'Donnell Owned by: nobody
Component: Database layer (models, ORM) Version: 1.8
Severity: Normal Keywords: mutli-value, valuequeryset
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

As I understand it, and from the error I received, trying to filter based on a multi-valued queryset cant be done (the error I received was something like "cant filter using multi-valued querysets"). It is possible that one may wish to filter based on a pair of values. Commutativity of the tuples should be considered. Eg Filter the following:

Object.objects.values_list("v1","v2").filter(AnotherObject.objects.values_list("v1","v2"))

Eg,
[(1,2),(5,7),(3,8),(9,3)].filter ([(1,2),(3,9)]) = [(5,7),(3,8),(9,3)]

here (9,3) == (3,9) is false. Non-commutative

For commutative comparison we have Eg,

[(1,2),(5,7),(3,8),(9,3)].filter ([(1,2),(3,9)]) = [(5,7),(3,8)]

here (9,3) == (3,9) is true.

The non-commutative case was necessary in an example I had. I hacked it where I created lists and compared using lists. However this requires a db evaluation.

Change History (2)

comment:1 Changed 4 years ago by Tim Graham

Could you refine the description with some actual models and sample code. It's a bit unclear as is. Thanks.

comment:2 Changed 4 years ago by Tim Graham

Resolution: needsinfo
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top