﻿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
29476	Filter with BooleanField produces invalid SQL for .query	Martin Gropp	nobody	"Hiho!

I ran into this issue today on 1.11.13:
I am using `.filter` on a QuerySet to select all elements that have a `BooleanField` set to true.
This works fine when run against the database, but the SQL produced by `QuerySet.query` is incorrect.

Here's an example:
{{{
class Foo(Model):
    bar = BooleanField()

query = str(Foo.objects.filter(bar=True).query)
}}}

Will produce SQL like this:
{{{
SELECT ""table"".""id"", ""table"".""bar"" FROM ""table"" WHERE ""table"".""bar"" = True
}}}

This will not work, because `True` is interpreted as a column name.

(I was trying to use this SQL as part of a raw query, and ended up working around the problem by replacing the `.filter` with another raw query casting `bar` to integer in the `where`.)


Cheers
Martin"	Bug	closed	Database layer (models, ORM)	1.11	Normal	invalid			Unreviewed	0	0	0	0	0	0
