[patch] depth handling in fill_table_cache broken when using select_related(depth=1).extra()
|Reported by:||Matthias Urlichs <smurf@…>||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Cc:||marcin@…, matthias@…, gabor@…||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
As reported by marcin@… in #3275:
There is a bug in the way depth is handled in fill_table_cache, see the attached patch for a test case. When you specify a non-zero depth fill_table_cache goes one relationship too deep which causes get_cached_row not to handle all the columns from select_related.
This bug shows up when you use extra on that QuerySet: the extra fields to select should immediately follow columns handled by get_cached_row, but instead they get data from the relationship that fill_table_cache added and get_cached_row skipped.
I'm re-posting this bug (and his patches) here because #3275 is, essentially, an unrelated ticket; IMHO this here patch should go into mainline ASAP.
Change History (7)
Changed 8 years ago by Matthias Urlichs <smurf@…>
comment:1 Changed 7 years ago by mtredinnick
- Keywords qs-rf added
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:3 Changed 7 years ago by Matthias Urlichs <smurf@…>
- Triage Stage changed from Unreviewed to Ready for checkin
comment:5 Changed 7 years ago by mtredinnick
- Keywords qs-rf-fixed added; qs-rf removed
- Triage Stage changed from Ready for checkin to Accepted