Opened 6 years ago

Closed 6 years ago

Last modified 4 years ago

#10572 closed (fixed)

defer() doesn't work cleanly with model inheritance

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

Description

Saving a model where an inherited field has been passed to defer() leads to badness (Django crashes :-( ).

I know about. I'll fix it for 1.1. Noting here in the hope that anybody else stumbling across this will discover it's a known issue for now. Working on beta-deadline things first, though.

Attachments (1)

defer-inheritance.diff (1008 bytes) - added by Alex 6 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 6 years ago by jacob

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Changed 6 years ago by Alex

comment:2 Changed 6 years ago by Alex

I can't reproduce with the above tests, is it possible it's either a) version specific, b) fixed in a previous patch, or c) I misunderstood the issue.

comment:3 Changed 6 years ago by byron

using only() doesn't work cleanly either. Given CustomUser which subclasses auth.User

CustomUser.objects.only("home_address").query.as_sql()

... retrieves "home_address" and all parent fields as well.

'SELECT "auth_user"."id", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email",
"auth_user"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_superuser", "auth_user"."last_login",
"auth_user"."date_joined", "users_customuser"."user_ptr_id", "users_customuser"."home_address" FROM "users_customuser" INNER
JOIN "auth_user" ON ("users_customuser"."user_ptr_id" = "auth_user"."id")'

comment:4 Changed 6 years ago by anonymous

  • Cc bruth@… added

comment:5 Changed 6 years ago by russellm

  • Owner changed from mtredinnick to russellm

I've got a test and patch for this; however, the test has introduced an order dependency in the test suite. I'll commit once I've got this sorted out.

comment:6 Changed 6 years ago by russellm

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

(In [10926]) Fixed #10572 -- Corrected the operation of the defer() and only() clauses when used on inherited models.

comment:7 Changed 6 years ago by ccahoon

(In [10995]) Fixed #10572 -- Corrected the operation of the defer() and only() clauses when used on inherited models.

comment:8 Changed 4 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top