Tuesday, December 23, 2014

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

Hi Will,

On Tue, Dec 23, 2014 at 3:56 PM, William Earp <bashy.pear@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. 

Russ Magee %-)

You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJxq84-2_RcOND5GwL0d301QrLxXY3mhKbm6AWcb57P8QYATJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment