Opened 18 years ago
Closed 17 years ago
#2496 closed defect (fixed)
select_related will cause table multiple times in FROM clause if table already in extra()
Reported by: | rezzrovv | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | normal | Keywords: | qs-rf-fixed |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
If a QuerySet is built or initialized with select_related and extra() and extra contains a table that will ultimately be iterated over through the select_related, that table will not be picked up in fill_table_cache. The result is a query with the table twice in the FROM clause and results in an DB error when executed (at least on postgresql, can't speak for any other DBs). Patch submitted. Example error from postgresql:
ProgrammingError: 'ERROR: table name "client" specified more than once
Attachments (1)
Change History (8)
by , 18 years ago
Attachment: | query.py.patch added |
---|
comment:1 by , 18 years ago
Keywords: | 3534 added |
---|---|
Version: | → SVN |
comment:2 by , 18 years ago
Component: | Core framework → Database wrapper |
---|---|
Owner: | changed from | to
comment:3 by , 17 years ago
Has patch: | set |
---|---|
Needs tests: | set |
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
Issue looks like a valid bug, but that's a hackish patch
comment:4 by , 17 years ago
Keywords: | qs-rf added |
---|
comment:5 by , 17 years ago
comment:6 by , 17 years ago
Keywords: | qs-rf-fixed added; 3534 qs-rf removed |
---|
comment:7 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
(In [7477]) Merged the queryset-refactor branch into trunk.
This is a big internal change, but mostly backwards compatible with existing
code. Also adds a couple of new features.
Fixed #245, #1050, #1656, #1801, #2076, #2091, #2150, #2253, #2306, #2400, #2430, #2482, #2496, #2676, #2737, #2874, #2902, #2939, #3037, #3141, #3288, #3440, #3592, #3739, #4088, #4260, #4289, #4306, #4358, #4464, #4510, #4858, #5012, #5020, #5261, #5295, #5321, #5324, #5325, #5555, #5707, #5796, #5817, #5987, #6018, #6074, #6088, #6154, #6177, #6180, #6203, #6658
patch for query error