Opened 8 years ago

Closed 4 years ago

#28087 closed New feature (wontfix)

Allow filtering and ordering with RawQuerySet

Reported by: Dmitriy Sintsov Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I implemented FilteredRawQuerySet which wraps around RawQuerySet and uses QuerySet to generate WHERE / ORDER BY statements for raw queries:

https://github.com/Dmitri-Sintsov/django-jinja-knockout/blob/master/django_jinja_knockout/query.py

It works with Django 1.8 to 1.11, but I had to fix it when database queries code were refactored in Django 1.9. So I am worrying a bit that new modifications can break it again.

Such querysets are useful when someone uses RAW queryset with ListViews which automatically generate filter() / order_by() arguments.

There is also a ListQuerySet which allows to query Prefetch object results as normal querysets. That allows to re-use the same code for different related queries.

If that is possible, it would be great to move such feature into the core. If the code is not good enough, then it could be reviewed and improved by core committer - if someone is interested, of course.

Change History (2)

comment:1 by Tim Graham, 8 years ago

Summary: RawQuerySet with filtering and ordering.Allow filtering and ordering with RawQuerySet
Triage Stage: UnreviewedSomeday/Maybe

I'm not sure about this. Perhaps you could raise the idea on the DevelopersMailingList to get feedback from a wider audience.

comment:2 by Mariusz Felisiak, 4 years ago

Resolution: wontfix
Status: newclosed
Triage Stage: Someday/MaybeUnreviewed

Personally I'm against adding support for filtering or ordering to the RawQuerySet. It sounds like a third-party package is the best way to proceed.

You can start a discussion on DevelopersMailingList if you don't agree.

Note: See TracTickets for help on using tickets.
Back to Top