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 JOIN exclude_modelthree U2 ON (U1.id = U2.model_one_id)
WHERE U2.id = %s ))'

Attachments (1)

more_info.txt (6.6 KB ) - added by Brent Hagany 16 years ago.
Test case models, demonstration of error, and stack trace

Download all attachments as: .zip

Change History (4)

by Brent Hagany, 16 years ago

Attachment: more_info.txt added

Test case models, demonstration of error, and stack trace

comment:1 by Brent Hagany, 16 years ago

Cc: brent.hagany@… added

comment:2 by Brent Hagany, 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.

comment:3 by Malcolm Tredinnick, 16 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #9188.

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