﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34940	"Filter queryset on ""tuples"" of values for multiple columns"	Xavier Blanchot	nobody	"Hi,

Let's say I have a model `Foo` with fields `a` and `b`, and I would like to build a `Foo` queryset filtering on some tuples of values for `(a,b)`. 
For example, assuming a list of values `mylist = [(""a1"",""b1""), (""a2"", ""b2"")])`, I want a filter that builds an SQL query with the following `WHERE` clause:
`WHERE (a,b) IN ((""a1"",""b1""), (""a2"", ""b2""))` (*).

I saw a similar question on StackOverFlow[https://stackoverflow.com/questions/20177749/django-filter-queryset-on-tuples-of-values-for-multiple-columns]. 
The two proposed answers are:
1. Use `Q` objects which results in a large query with several `AND` and `OR` clauses
2. Use raw SQL, which I would rather avoid.

I'd rather have a query with a clause like in `(*)` so I coded a small filter function which can be used as follows: reusing the previous example, `Foo.objects.filter(FieldsIn(""a"", ""b"", values=((""a1"",""b1""), (""a2"", ""b2"")) ))`. This `FieldsIn` function inherits from `django.db.models.Func` and builds the SQL query presented above.

Do you think it's a good idea to integrate such a feature in Django? Otherwise how would you do it? 
If my proposition looks good to you I can propose a patch. "	New feature	closed	Database layer (models, ORM)	4.2	Normal	duplicate	Filter		Unreviewed	0	0	0	0	0	0
