From 34bf9e8d31d8448ff159bcab60014d9b7acbbc71 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Tue, 31 Jan 2006 01:50:16 +0000 Subject: [PATCH] magic-removal: Fixed bug with .values() when no arguments are passed, and added test for it git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2197 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/query.py | 2 +- tests/modeltests/lookup/models.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/django/db/models/query.py b/django/db/models/query.py index d58f488ed4..016cd2a1e3 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -217,7 +217,7 @@ class QuerySet(object): if not rows: raise StopIteration for row in rows: - yield dict(zip(fields, row)) + yield dict(zip(columns, row)) def dates(self, field_name, kind, order='ASC'): """ diff --git a/tests/modeltests/lookup/models.py b/tests/modeltests/lookup/models.py index 4d557fec5f..6364ffe6fd 100644 --- a/tests/modeltests/lookup/models.py +++ b/tests/modeltests/lookup/models.py @@ -103,6 +103,10 @@ True [('headline', 'Article 7'), ('id', 7)] [('headline', 'Article 1'), ('id', 1)] +# if you don't specify which fields, all are returned +>>> list(Article.objects.filter(id=5).values()) == [{'id': 5, 'headline': 'Article 5', 'pub_date': datetime(2005, 8, 1, 9, 0)}] +True + # Every DateField and DateTimeField creates get_next_by_FOO() and # get_previous_by_FOO() methods. # In the case of identical date values, these methods will use the ID as a