Opened 8 years ago

Closed 8 years ago

#9192 closed (duplicate)

exclude() fails; generates query using bad table alias

Reported by: bhagany 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: UI/UX:


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.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 ( = U2.model_one_id)
WHERE = %s ))'

Attachments (1)

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

Download all attachments as: .zip

Change History (4)

Changed 8 years ago by bhagany

Test case models, demonstration of error, and stack trace

comment:1 Changed 8 years ago by bhagany

  • Cc brent.hagany@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 8 years ago by bhagany

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 Changed 8 years ago by mtredinnick

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #9188.

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