mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #17602 -- Stopped the XML serializer from doing unneeded queries. Thanks, gnosek.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17439 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -178,6 +178,19 @@ class SerializersTestBase(object):
|
||||
mv_obj = obj_list[0].object
|
||||
self.assertEqual(mv_obj.title, movie_title)
|
||||
|
||||
def test_serialize_superfluous_queries(self):
|
||||
"""Ensure no superfluous queries are made when serializing ForeignKeys
|
||||
|
||||
#17602
|
||||
"""
|
||||
ac = Actor(name='Actor name')
|
||||
ac.save()
|
||||
mv = Movie(title='Movie title', actor_id=ac.pk)
|
||||
mv.save()
|
||||
|
||||
with self.assertNumQueries(0):
|
||||
serial_str = serializers.serialize(self.serializer_name, [mv])
|
||||
|
||||
def test_serialize_with_null_pk(self):
|
||||
"""
|
||||
Tests that serialized data with no primary key results
|
||||
|
||||
Reference in New Issue
Block a user