#14229 closed (duplicate)
Postgres backend generates invalid SQL when istartswith and F object are combined.
Reported by: | Ales Zoulek | Owned by: | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | postgres database F | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Change History (2)
comment:1 by , 14 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:2 by , 12 years ago
Component: | ORM aggregation → Database layer (models, ORM) |
---|
Note:
See TracTickets
for help on using tickets.
This looks like a duplicate of #11722.