diff options
author | Adnan Umer <u.adnan@outlook.com> | 2018-04-18 22:25:59 +0500 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2018-04-19 11:35:49 -0400 |
commit | ec0319ff821492783f555917b61bceacddb77571 (patch) | |
tree | c6622fee55ea142838285db8b185e4ea079c7cd8 /tests/raw_query | |
parent | c1c163b42717ed5e051098ebf0e2f5c77810f20e (diff) | |
download | django-ec0319ff821492783f555917b61bceacddb77571.tar.gz |
Fixed #29339 -- Added result caching to RawQuerySet.
Diffstat (limited to 'tests/raw_query')
-rw-r--r-- | tests/raw_query/tests.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/raw_query/tests.py b/tests/raw_query/tests.py index bcc075ea35..1f0d0c363f 100644 --- a/tests/raw_query/tests.py +++ b/tests/raw_query/tests.py @@ -318,3 +318,15 @@ class RawQueryTests(TestCase): c = Coffee.objects.create(brand='starbucks', price=20.5) qs = Coffee.objects.raw("SELECT * FROM raw_query_coffee WHERE price >= %s", params=[Decimal(20)]) self.assertEqual(list(qs), [c]) + + def test_result_caching(self): + with self.assertNumQueries(1): + books = Book.objects.raw('SELECT * FROM raw_query_book') + list(books) + list(books) + + def test_iterator(self): + with self.assertNumQueries(2): + books = Book.objects.raw('SELECT * FROM raw_query_book') + list(books.iterator()) + list(books.iterator()) |