#28497: QuerySet.filter() with a sliced QuerySet crashes
-------------------------------------+-------------------------------------
     Reporter:  Sergey Fedoseev      |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

 Here's a regression test. It's not clear to me why this shouldn't be
 allowed. What should the error message say?
 {{{ #!diff
 diff --git a/tests/lookup/tests.py b/tests/lookup/tests.py
 index 25098af..7eeaa26 100644
 --- a/tests/lookup/tests.py
 +++ b/tests/lookup/tests.py
 @@ -138,6 +138,12 @@ class LookupTests(TestCase):
          with self.assertNumQueries(expected_num_queries):
              self.assertEqual(Author.objects.in_bulk(authors.keys()),
 authors)

 +    def test_filter_with_sliced(self):
 +         self.assertSequenceEqual(
 +            Article.objects.filter(author=Author.objects.all()[:1]),
 +            [self.a4, self.a2, self.a3, self.a1],
 +        )
 +
      def test_values(self):
          # values() returns a list of dictionaries instead of object
 instances --
          # and you can specify which fields you want to retrieve.
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28497#comment:5>
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/068.7ec4c67d1983175d1a06d25c6c58c7bd%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to