mirror of https://github.com/django/django.git
Simplified check that pk is fetched in RawQuerySet.__iter__().
This commit is contained in:
parent
5d9034bc92
commit
7bd9639406
|
@ -1220,15 +1220,8 @@ class RawQuerySet:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
model_init_names, model_init_pos, annotation_fields = self.resolve_model_init_order()
|
model_init_names, model_init_pos, annotation_fields = self.resolve_model_init_order()
|
||||||
|
if self.model._meta.pk.attname not in model_init_names:
|
||||||
# Find out which model's fields are not present in the query.
|
raise InvalidQuery('Raw query must include the primary key')
|
||||||
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')
|
|
||||||
model_cls = self.model
|
model_cls = self.model
|
||||||
fields = [self.model_fields.get(c) for c in self.columns]
|
fields = [self.model_fields.get(c) for c in self.columns]
|
||||||
converters = compiler.get_converters([
|
converters = compiler.get_converters([
|
||||||
|
|
Loading…
Reference in New Issue