#26108: New method for returning OR querysets
----------------------------------------------+--------------------
     Reporter:  MrMe99                        |      Owner:  nobody
         Type:  New feature                   |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  master
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 It would be nice if you guys created a new method that would allow for OR
 querysets to be returned.

 Right now you can use <model>.objects.filter() in conjunction with the q()
 method but this is limiting since you have to have all the ORs in a single
 filter statement.  If you where to chain another filter statement the two
 would be ANDed.

 It would be helpful to have another method that would OR the chained
 results together.  This is helpful when you have conditional cases and
 need to build the queryset up.

 Example:
 Say i have an object I'm querying and the query looks like this so far:

 query = <model>.objects.filter( (Q(id=2) & Q(state=1)) |  (Q(id=3) &
 (state = 2)) ... )

 Now lets say I want to append another OR to the end of the query if the
 current logged in user is and admin.  Currently I would have to write a
 conditional statement and duplicate the query in two places except the
 query with the if user.is_admin would have some additional conditions.

 It would be ideal if we could just append another statement with an OR to
 the current query:
 example :   query.include( Q(id=8) & Q(state=3))

 This would allow greater flexibility and prevent wet code.

--
Ticket URL: <https://code.djangoproject.com/ticket/26108>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.ea0df5e451b7329aa21c26809f8eb0ba%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to