Opened 15 years ago

Closed 15 years ago

Last modified 13 years ago

#10572 closed (fixed)

defer() doesn't work cleanly with model inheritance

Reported by: Malcolm Tredinnick Owned by: Russell Keith-Magee
Component: Database layer (models, ORM) Version: dev
Severity: Keywords:
Cc: bruth@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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 Gaynor 15 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 by Jacob, 15 years ago

Triage Stage: UnreviewedAccepted

by Alex Gaynor, 15 years ago

Attachment: defer-inheritance.diff added

comment:2 by Alex Gaynor, 15 years ago

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 by byron, 15 years ago

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 by anonymous, 15 years ago

Cc: bruth@… added

comment:5 by Russell Keith-Magee, 15 years ago

Owner: changed from Malcolm Tredinnick to Russell Keith-Magee

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 by Russell Keith-Magee, 15 years ago

Resolution: fixed
Status: newclosed

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

comment:7 by ccahoon, 15 years ago

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

comment:8 by Jacob, 13 years ago

milestone: 1.1

Milestone 1.1 deleted

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