summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2017-08-02 02:05:21 +0500
committerTim Graham <timograham@gmail.com>2017-08-02 08:56:16 -0400
commit7bd96394063df5372972fcfc6189dfaa0425a288 (patch)
treec4e291a8b4ceeca71cdcfd38bb1bd1c973e30da3
parent5d9034bc92e9def0785a3b7cd9ca65e284db0191 (diff)
Simplified check that pk is fetched in RawQuerySet.__iter__().
-rw-r--r--django/db/models/query.py11
1 files changed, 2 insertions, 9 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py
index aabd4d7a54..c625da4bdc 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -1220,15 +1220,8 @@ class RawQuerySet:
try:
model_init_names, model_init_pos, annotation_fields = self.resolve_model_init_order()
-
- # Find out which model's fields are not present in the query.
- skip = set()
- for field in self.model._meta.fields:
- if field.attname not in model_init_names:
- skip.add(field.attname)
- if skip:
- if self.model._meta.pk.attname in skip:
- raise InvalidQuery('Raw query must include the primary key')
+ if self.model._meta.pk.attname not in model_init_names:
+ raise InvalidQuery('Raw query must include the primary key')
model_cls = self.model
fields = [self.model_fields.get(c) for c in self.columns]
converters = compiler.get_converters([