defer() and only() chaining bug

16 views
Skip to first unread message

William Earp

unread,
Dec 23, 2014, 6:45:00 AM12/23/14
to django...@googlegroups.com
Hi all,

I'm currently writing unit tests for defer() and only() under issue #18586. But there appears to a bug when it comes to chaining the two together.

The docs gives the following example for only():

# Final result loads headline and body immediately (only() replaces any existing set of fields).

Entry.objects.defer("body").only("headline", "body")


It turns out that "body" remains a DeferredAttribute when it shouldn't. So in the example above, if the model contained just the two fields "headline" and "body" there wouldn't be any deferred field. In my tests "body" is still a DeferredAttribute.

Am I getting this right or is this actually a bug?

Cheers,

Will

Collin Anderson

unread,
Dec 26, 2014, 4:11:05 PM12/26/14
to django...@googlegroups.com
Hi Will,

Yes and yes. I just confirmed it myself.

Collin
Reply all
Reply to author
Forward
0 new messages