﻿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
2457	manytomany __id__in filters do not work correctly with the sqlite3 backend	gabor@…	Adrian Holovaty	"imagine the following models:

{{{
class A(Model):
    name = CharField(maxlength=200)

class B(Model):
    title = CharField(maxlength=200)
    rel = ManyToManyField(A)
}}}

now, if i create the following instances:

{{{
a1 = A.objects.create( name='a1')
a2 = A.objects.create( name='a2')

b1 = B.objects.create( title='b1')
b2 = B.objects.create( title='b2')

b1.rel = [a1]
b2.rel = [a2]

b1.save()
b2.save()
}}}

and now do the following queries:
{{{
B.objects.filter(rel__id = a1.id)
B.objects.filter(rel__id__in = [a1.id])
}}}
i should get identical results. but no.
i get:
{{{
[<B: b1>]
[<B: b1>, <B: b2>]
}}}
which is incorrect. 
the correct answer would be
{{{
[<B: b1>]
[<B: b1>]
}}}

with postgresql backend this works correctly.

also when filtering using non-id fields, the ""in filtering"" works ok in sqlite3.
for example these two queries generate identical (and correct) results in sqlite3:
{{{
B.objects.filter(rel__name = 'a1')
B.objects.filter(rel__name__in = ['a1'])

[<B: b1>]
[<B: b1>]
}}}


i tested this on mac-osx, sqlite 3.3.5, python 2.4.2 (from darwinports)"	defect	closed	Database layer (models, ORM)		normal	invalid			Unreviewed	0	0	0	0	0	0
