Opened 16 years ago

Last modified 13 years ago

#7957 closed

Chaining Queryset.extra() methods that contain parameters breaks the query — at Initial Version

Reported by: Matthijs Owned by: Matthijs
Component: Database layer (models, ORM) Version: dev
Severity: Keywords: queryset extra select select_params
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

To reproduce:

Precondition a user 'root' exists with id=1

from django.contrib.auth.models import User
for result in User.objects.extra(select=

{'foo3': "SELECT COUNT(auth_user.id) FROM auth_user WHERE (auth_user.username = %s)"}
, select_params=root).extra(select=
{'foo2': "SELECT COUNT(auth_user.id) FROM auth_user WHERE (auth_user.id = %s)"}
, select_params=1):

print result.foo3

# output should be:
# 1
# 1
for result in User.objects.extra(select=

{'foo1': "SELECT COUNT(auth_user.id) FROM auth_user WHERE (auth_user.username = %s)"}
, select_params=root).extra(select=
{'foo2': "SELECT COUNT(auth_user.id) FROM auth_user WHERE (auth_user.id = %s)"}
, select_params=1):

print result.foo1

# output should be:
# 1
# 1

Change History (2)

by Matthijs, 16 years ago

Attachment: django_extra.diff added

patch to fix extra().extra() problem

by Matthijs, 16 years ago

Attachment: reproduce_extra_problem.py added

file that demonstrated bug

Note: See TracTickets for help on using tickets.
Back to Top