Django

Code

Ticket #2038 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

QuerySet._combine does not combine where clause

Reported by: graham@darkcoding.net Assigned to: adrian
Milestone: Component: Admin interface
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

In db/models/query.py, QuerySet?, the _combine method does not actually combine the two query sets. Instead if clones the second one and returns that.

To reproduce:

- Create a custom manager for an object that uses the admin interface, and has a search box.

- Make that custom manager change the 'where' clause of it's query set, for example by using the 'extra' method to limit the query via a join.

- List the objects in the admin interface. You will see the limited set, which is correct.

- Use the search box on the list admin page. The results now returned are not limited by your manager, because the 'where' clause gets lost.

Attachments

Change History

05/30/06 11:32:52 changed by graham@darkcoding.net

Adding this in QuerySet?._combine from line 384 fixes it:

        if self._select: combined._select.update(self._select)
        if self._where: combined._where.extend(self._where)
        if self._params: combined._params.extend(self._params)
        if self._tables: combined._tables.extend(self._tables) 

I can provide a patch if needed.

05/31/06 09:52:34 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

(In [3019]) Fixed #2038 -- QuerySet?._combine now combines where clause. Thanks, graham@darkcoding.net


Add/Change #2038 (QuerySet._combine does not combine where clause)




Change Properties
Action