-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Enhance AppenderQuery to support __len__ (but still not issue needless COUNT) #818
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
Comments
Anonymous wrote: Demonstration of the issue |
Changes by Anonymous:
|
Changes by Michael Bayer (@zzzeek):
|
jek (@jek) wrote: ebroder points out that changing
|
Changes by jek (@jek):
|
jek (@jek) wrote: ...and ebroder further points out that the iter suggestion was in the original report. :) |
Michael Bayer (@zzzeek) wrote: I'm not really sold on this, I think the fact that calling list(obj.collection) versus obj.collection.all() has a performance hit is surprise, but silent, behavior. Whereas calling len() and getting an error is somewhat less surprising (since its consistent with |
Changes by Michael Bayer (@zzzeek):
|
Changes by Michael Bayer (@zzzeek):
|
Michael Bayer (@zzzeek) wrote: Closing this since list(q) is the usual way to get the result as a list IMHO |
Changes by Michael Bayer (@zzzeek):
|
Migrated issue, originally created by Anonymous
Currently, using .all() on an AppenderQuery object (from a dynamic_loader) will generate two queries: a
SELECT
, and an unnecessarySELECT COUNT()
. This is becauselist()
is calling__len__
.This could be fixed by removing
__len__
, or by overridingall()
to returnlist(iter(self))
instead of justlist(self)
.Attachments: example.py
The text was updated successfully, but these errors were encountered: