Opened 16 years ago

Closed 16 years ago

Last modified 12 years ago

#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)

annotation_test.diff (1.3 KB ) - added by Ben Anhalt 16 years ago.

Download all attachments as: .zip

Change History (5)

by Ben Anhalt, 16 years ago

Attachment: annotation_test.diff added

comment:1 by Ben Anhalt, 16 years ago

Component: UncategorizedORM aggregation
Owner: nobody removed

comment:2 by Jacob, 16 years ago

Resolution: wontfix
Status: newclosed

This is a "if it hurts then stop doing that" situation: get_query_set is expected to return a (relatively) clean queryset.

in reply to:  2 comment:3 by Shaun Cutts, 15 years ago

Cc: shaun@… 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 Anssi Kääriäinen, 12 years ago

Component: ORM aggregationDatabase layer (models, ORM)
Note: See TracTickets for help on using tickets.
Back to Top