Code

Opened 4 years ago

Closed 4 years ago

Last modified 14 months ago

#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: master
Severity: Keywords: postgres database F
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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.

Attachments (0)

Change History (2)

comment:1 Changed 4 years ago by mlavin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

This looks like a duplicate of #11722.

comment:2 Changed 14 months ago by akaariai

  • Component changed from ORM aggregation to Database layer (models, ORM)

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.