query="SELECT id, first_name, dob FROM raw_query_author"
query="SELECT id, first_name, dob FROM raw_query_author"
forauthorinAuthor.objects.raw(query):
forauthorinAuthor.objects.raw(query):
self.assertNotEqual(author.first_name,None)
self.assertNotEqual(author.first_name,None)
# last_name isn't given, but it will be retrieved on demand
# last_name isn't given, but it will be retrieved on demand
self.assertNotEqual(author.last_name,None)
self.assertNotEqual(author.last_name,None)
deftestMissingFieldsWithoutPK(self):
deftest_missing_fields_without_PK(self):
query="SELECT first_name, dob FROM raw_query_author"
query="SELECT first_name, dob FROM raw_query_author"
try:
try:
list(Author.objects.raw(query))
list(Author.objects.raw(query))
...
@@ -181,7 +181,7 @@ class RawQueryTests(TestCase):
...
@@ -181,7 +181,7 @@ class RawQueryTests(TestCase):
exceptInvalidQuery:
exceptInvalidQuery:
pass
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"
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=(
expected_annotations=(
('book_count',3),
('book_count',3),
...
@@ -192,12 +192,12 @@ class RawQueryTests(TestCase):
...
@@ -192,12 +192,12 @@ class RawQueryTests(TestCase):