Re: potential bug with defer() & only()

18 views
Skip to first unread message

Russell Keith-Magee

unread,
Dec 23, 2014, 10:49:56 PM12/23/14
to Django Users
Hi Will,

On Tue, Dec 23, 2014 at 3:56 PM, William Earp <bashy...@gmail.com> wrote:
Hi all,

I'm writing some tests #18586) for defer() and only() and there appears to be a bug when it comes to chaining these two in a single query.


# Final result is that everything except "headline" is deferred.
Entry.objects.only("headline", "body").defer("body")

# Final result loads headline and body immediately (only() replaces any
# existing set of fields).
Entry.objects.defer("body").only("headline", "body")
However, when I test the last example "body" is still deferred after only() has been applied to it. In a situation where there are only these two fields in a model there should be no deferred field. 
Is there any reason for this or does this need reporting as a bug. If so, what's the procedure for this?
Well, either the code is wrong or the documentation is wrong, so *something* needs to be changed. The documentation describes what I understood to be Django's behavior, so it if isn't working like that, then it sounds like you've found a bug.

To report it, visit


and on the top left, there's a "New ticket" button. (You may need to log in first - either with your Github account, or by creating a Django Project account).

Fill in the details (pretty much what you've done here, but also provide Django + Python version numbers, and the database you're testing with), and someone else will try to replicate the problem you describe. 

Yours
Russ Magee %-)
Reply all
Reply to author
Forward
0 new messages