query="SELECT id, first_name, dob FROM raw_query_author"
forauthorinAuthor.objects.raw(query):
self.assertNotEqual(author.first_name,None)
# last_name isn't given, but it will be retrieved on demand
self.assertNotEqual(author.last_name,None)
deftestMissingFieldsWithoutPK(self):
deftest_missing_fields_without_PK(self):
query="SELECT first_name, dob FROM raw_query_author"
try:
list(Author.objects.raw(query))
...
...
@@ -181,7 +181,7 @@ class RawQueryTests(TestCase):
exceptInvalidQuery:
pass
deftestAnnotations(self):
deftest_annotations(self):
query="SELECT a.*, count(b.id) as book_count FROM raw_query_author a LEFT JOIN raw_query_book b ON a.id = b.author_id GROUP BY a.id, a.first_name, a.last_name, a.dob ORDER BY a.id"
expected_annotations=(
('book_count',3),
...
...
@@ -192,12 +192,12 @@ class RawQueryTests(TestCase):