-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling len() on a QuerySet object mid-iteration stops iteration at current hundred documents #1086
Comments
Anybody? |
Hi, sorry for the delay of the response... Concerning your issue, it's obviously a cache trouble: the Fixing this issue seems a bit complicated given we should have a lazy cache that could be partially populated (chunk by chunk) by any iterator (each keeping it own current state) I think it could be easier to add some information about this behavior in the documentation (and to raise an exception if the reentrant call is done on the object) and to redirect the user on the |
I'd be happy with an exception being raised - that's a lot better than not knowing you're getting incomplete results. |
I made a pass at fixing this, and it seems to be working now, but I'm not sure whether this will have further ramifications... I'm not familiar enough with how these QuerySets are being implemented to know this won't break anything... but... your test passes now, and I'm using this change in production with no noticeable issues yet... knock on wood |
Also, perhaps related? When I set no_cache() I get the following error when trying to check the length of the QuerySet:
This happening is what prompted me to try to fix this. |
I just proposed a proper fix for this in #1427 |
Thanks for the fix @wojcikstefan! |
Please see PR #1072 for a test demonstrating this behavior.
The text was updated successfully, but these errors were encountered: