Opened 15 years ago
Last modified 9 years ago
#11329 closed
get_count generates incorrect SQL for query sets with extra 'select' and 'where' — at Version 1
Reported by: | bogklug | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.0 |
Severity: | Normal | Keywords: | sql, extra select, extra where, get_count |
Cc: | markus.magnuson@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Extending an example on extra 'select' from http://docs.djangoproject.com/en/1.0/ref/models/querysets/ with an extra 'with' and calling get_count:
Blog.objects.extra( select={ 'entry_count': 'SELECT COUNT(*) FROM blog_entry WHERE blog_entry.blog_id = blog_blog.id' }, where=['entry_count=0'] ).query.get_count()
results in OperationalError: no such column: entry_count.
The SQL for the query itself is ok. It seems that the problem is caused by get_count.
Change History (2)
comment:1 by , 15 years ago
Description: | modified (diff) |
---|
by , 15 years ago
Attachment: | sql-get-count-with-select-extra.patch added |
---|
Check for extra_select in get_count
Note:
See TracTickets
for help on using tickets.
Please use the preview option. Also, are you using the internal get_count() function instead of the public count() API.