Ticket #7235: 7235.diff

File 7235.diff, 2.1 KB (added by aljosa, 16 years ago)

EmptyQuerySet methods all, filter, exclude, complex_filter, select_related, annotate, order_by, distinct, extra, reverse, defer and only "return self"

  • django/db/models/query.py

     
    910910        # (it raises StopIteration immediately).
    911911        yield iter([]).next()
    912912
     913    def all(self):
     914        """
     915        Always returns EmptyQuerySet.
     916        """
     917        return self
     918
     919    def filter(self, *args, **kwargs):
     920        """
     921        Always returns EmptyQuerySet.
     922        """
     923        return self
     924
     925    def exclude(self, *args, **kwargs):
     926        """
     927        Always returns EmptyQuerySet.
     928        """
     929        return self
     930
     931    def complex_filter(self, filter_obj):
     932        """
     933        Always returns EmptyQuerySet.
     934        """
     935        return self
     936
     937    def select_related(self, *fields, **kwargs):
     938        """
     939        Always returns EmptyQuerySet.
     940        """
     941        return self
     942
     943    def annotate(self, *args, **kwargs):
     944        """
     945        Always returns EmptyQuerySet.
     946        """
     947        return self
     948
     949    def order_by(self, *field_names):
     950        """
     951        Always returns EmptyQuerySet.
     952        """
     953        return self
     954
     955    def distinct(self, true_or_false=True):
     956        """
     957        Always returns EmptyQuerySet.
     958        """
     959        return self
     960
     961    def extra(self, select=None, where=None, params=None, tables=None,
     962              order_by=None, select_params=None):
     963        """
     964        Always returns EmptyQuerySet.
     965        """
     966        assert self.query.can_filter(), \
     967                "Cannot change a query once a slice has been taken"
     968        return self
     969
     970    def reverse(self):
     971        """
     972        Always returns EmptyQuerySet.
     973        """
     974        return self
     975
     976    def defer(self, *fields):
     977        """
     978        Always returns EmptyQuerySet.
     979        """
     980        return self
     981
     982    def only(self, *fields):
     983        """
     984        Always returns EmptyQuerySet.
     985        """
     986        return self
     987
    913988    # EmptyQuerySet is always an empty result in where-clauses (and similar
    914989    # situations).
    915990    value_annotation = False
Back to Top