#10673 closed (wontfix)
If the default manager adds an annotation and sets use_for_related_fields, saves can fail.
Reported by: | Ben Anhalt | Owned by: | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | ||
Cc: | shaun@… | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
If a model has a custom manager that sets use_for_related_fields = True and overrides get_query_set() to return an annotated query set, then calling save() on instances of that model can fail with ProgrammingError: subquery has too many columns.
I am attaching a diff with a test illustrating this behavior.
Attachments (1)
Change History (5)
by , 16 years ago
Attachment: | annotation_test.diff added |
---|
comment:1 by , 16 years ago
Component: | Uncategorized → ORM aggregation |
---|---|
Owner: | removed |
follow-up: 3 comment:2 by , 16 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:3 by , 14 years ago
Cc: | added |
---|
Replying to jacob:
This is a "if it hurts then stop doing that" situation:
get_query_set
is expected to return a (relatively) clean queryset.
Ok ... but then this should be documented in the "get_query_set" documentation IMHO. I ran into this while trying to optimize; it made a great difference in timing without much work, so its sort of shame it isn't actually possible, though of course there are other ways to get around this.
... thanks for all the hard work!
-- Shaun
comment:4 by , 12 years ago
Component: | ORM aggregation → Database layer (models, ORM) |
---|
This is a "if it hurts then stop doing that" situation:
get_query_set
is expected to return a (relatively) clean queryset.