Code

Opened 5 years ago

Closed 5 years ago

Last modified 14 months ago

#10673 closed (wontfix)

If the default manager adds an annotation and sets use_for_related_fields, saves can fail.

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

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 benanhalt 5 years ago.

Download all attachments as: .zip

Change History (5)

Changed 5 years ago by benanhalt

comment:1 Changed 5 years ago by benanhalt

  • Component changed from Uncategorized to ORM aggregation
  • Needs documentation unset
  • Needs tests unset
  • Owner nobody deleted
  • Patch needs improvement unset

comment:2 follow-up: Changed 5 years ago by jacob

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

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

comment:3 in reply to: ↑ 2 Changed 4 years ago by shauncutts

  • 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 Changed 14 months ago by akaariai

  • Component changed from ORM aggregation to Database layer (models, ORM)

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.