Ticket #12142: django_emptyqueryset_withtest.diff

File django_emptyqueryset_withtest.diff, 797 bytes (added by cwebber, 6 years ago)

Updated "patch with overriden update() returning 0", with a test

  • django/db/models/query.py

    diff --git a/django/db/models/query.py b/django/db/models/query.py
    index 0b57b1e..39c754f 100644
    a b class EmptyQuerySet(QuerySet): 
    10011001    def count(self):
    10021002        return 0
    10031003
     1004    def update(self, **kwargs):
     1005        return 0
     1006
    10041007    def delete(self):
    10051008        pass
    10061009
  • tests/modeltests/lookup/models.py

    diff --git a/tests/modeltests/lookup/models.py b/tests/modeltests/lookup/models.py
    index 512ffd7..6c86dad 100644
    a b DoesNotExist: Article matching query does not exist. 
    295295[]
    296296>>> Article.objects.none().count()
    2972970
     298>>> Article.objects.none().update(headline="Don't update me bro")
     2990
    298300>>> [article for article in Article.objects.none().iterator()]
    299301[]
    300302
Back to Top