Handle non-distinct results from base object query

fix_request_path_info
Jedediah Smith 2012-11-29 15:38:40 -05:00 committed by Diederik van der Boor
parent ea9cb91e78
commit 1a6f3a45e5
1 changed files with 15 additions and 18 deletions

View File

@ -151,13 +151,10 @@ class PolymorphicQuerySet(QuerySet):
ordered_id_list.append(base_object.pk) 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=...) # 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, ( if not base_object.pk in base_result_objects_by_id:
"django_polymorphic: result objects do not have unique primary keys - model " + unicode(self.model)
)
base_result_objects_by_id[base_object.pk] = base_object 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 # Real class is exactly the same as base class, go straight to results
results[base_object.pk] = base_object results[base_object.pk] = base_object