Handle non-distinct results from base object query
parent
ea9cb91e78
commit
1a6f3a45e5
|
|
@ -151,13 +151,10 @@ class PolymorphicQuerySet(QuerySet):
|
|||
ordered_id_list.append(base_object.pk)
|
||||
|
||||
# check if id of the result object occeres more than once - this can happen e.g. with base_objects.extra(tables=...)
|
||||
assert not base_object.pk in base_result_objects_by_id, (
|
||||
"django_polymorphic: result objects do not have unique primary keys - model " + unicode(self.model)
|
||||
)
|
||||
|
||||
if not base_object.pk in base_result_objects_by_id:
|
||||
base_result_objects_by_id[base_object.pk] = base_object
|
||||
|
||||
if (base_object.polymorphic_ctype_id == self_model_class_id):
|
||||
if base_object.polymorphic_ctype_id == self_model_class_id:
|
||||
# Real class is exactly the same as base class, go straight to results
|
||||
results[base_object.pk] = base_object
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue