Skip to content
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

Implement LimitedQuerySet class #9

Open
onyb opened this issue Mar 20, 2017 · 0 comments
Open

Implement LimitedQuerySet class #9

onyb opened this issue Mar 20, 2017 · 0 comments

Comments

@onyb
Copy link
Owner

onyb commented Mar 20, 2017

The result returned by some QuerySet methods do not allow chaining with other methods due to their form. For example, the result of a value_list will not allow operations like order_by.

Any QuerySet method which returns a result where the items are not Model instances qualify to return instances of type LimitedQuerySet.

Example use case:

>>> Foo.objects.filter(...).values_list('pk', 'name', 'idx')
[(123, 'A', 0,), (124, 'B', 1,), ...]  # LimitedQuerySet

>>> Foo.objects.filter(...).values_list('pk', 'name', 'idx').map(lambda c: hash(c))
[-8396369143964016954, 3966759431255512253, ...]  # LimitedQuerySet
@onyb onyb self-assigned this Mar 20, 2017
@onyb onyb removed their assignment Nov 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant