﻿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
14229	Postgres backend generates invalid SQL when istartswith and F object are combined.	Ales Zoulek		"How to reproduce:

It's quite easy, just try:

{{{
In [1]: from django.db.models import F

In [2]: from django.contrib.auth.models import User

In [3]: str(User.objects.filter(first_name__istartswith=F('username')).query)
Out[3]: 'SELECT ""auth_user"".""id"", ""auth_user"".""username"", ""auth_user"".""first_name"", ""auth_user"".""last_name"",
 ""auth_user"".""email"", ""auth_user"".""password"", ""auth_user"".""is_staff"", ""auth_user"".""is_active"", ""auth_user"".""is_superuser"", 
 ""auth_user"".""last_login"", ""auth_user"".""date_joined"" FROM ""auth_user"" WHERE UPPER(""auth_user"".""first_name""::text) LIKE 
 UPPER() ""auth_user"".""username""'
}}}

See the invalid closed UPPER() function at the end. This queryset will ofcourse raise DatabaseError when executed.
"		closed	Database layer (models, ORM)	dev		duplicate	postgres database F		Unreviewed	0	0	0	0	0	0
