Opened 16 years ago
Closed 16 years ago
#9192 closed (duplicate)
exclude() fails; generates query using bad table alias
Reported by: | Brent Hagany | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.0 |
Severity: | Keywords: | exclude filter alias | |
Cc: | brent.hagany@… | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The ORM generates a query that attempts to use a table alias (U1) that it did not create, when performing joins across multiple (at least 3) models that are related as in the attachment. The invalid query generated is:
'SELECT exclude_modeltwo
.id
, exclude_modeltwo
.model_one_id
FROM exclude_modeltwo
WHERE NOT (exclude_modeltwo
.model_one_id
IN (SELECT U2.
model_one_id
FROM
exclude_modeltwo
U0
INNER JOINexclude_modelthree
U2 ON (U1.id
= U2.model_one_id
)
WHERE U2.id
= %s ))'
Attachments (1)
Change History (4)
by , 16 years ago
Attachment: | more_info.txt added |
---|
comment:1 by , 16 years ago
Cc: | added |
---|
comment:2 by , 16 years ago
Should probably mention that this is using mysql. Also, I'm going to look into this and see if I can provide a patch, but I don't know the code very well, so no guarantees.
Test case models, demonstration of error, and stack trace