Opened 18 years ago

Closed 18 years ago

#3740 closed (duplicate)

Django creates wrong query for postgresql 8.1

Reported by: me@… Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'm getting a programming error 'missing FROM-clause entry for table "mail_domain"'. The query that django constructed was:

'SELECT "mail_alias"."id","mail_alias"."address","mail_alias"."domain_id","mail_alias"."enabled" FROM "mail_alias" ORDER BY "mail_domain"."name" ASC'

which works when I add mail_domain to the from-clause as

'SELECT "mail_alias"."id","mail_alias"."address","mail_alias"."domain_id","mail_alias"."enabled" FROM "mail_alias", "mail_domain" ORDER BY "mail_domain"."name" ASC'

The model for Alias which triggers the bug is attached. I'm using the current (r4739) trunk.

Attachments (1)

models.py (560 bytes ) - added by anonymous 18 years ago.
contains only the "Alias"-model which triggers the bug

Download all attachments as: .zip

Change History (3)

by anonymous, 18 years ago

Attachment: models.py added

contains only the "Alias"-model which triggers the bug

comment:1 by me@…, 18 years ago

This occures with both postgresql-backends. It seems to be caused by Alias' str-method (see attached file).

if class Admin contains

list_display = ('__str__', 'enabled')

it fails, because str is built from both self.name and self.domain.name. if it contains

list_display = ('__str__', 'domain', 'enabled')

it works, because "domain" is explicitly included.

comment:2 by James Bennett, 18 years ago

Resolution: duplicate
Status: newclosed

I strongly suspect that this is a duplicate of #2076, since the buggy behavior -- Django fails to add a related table name to the SELECT clause -- is identical. Closing as a dupe for now, but if this turns out not to be the same bug it should be reopened.

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