1
0
mirror of https://github.com/django/django.git synced 2025-10-29 00:26:07 +00:00

[1.8.x] Fixed #24912 -- Fixed prefetch_related failure for UUIDField primary keys

This resolves a problem on databases besides PostgreSQL when using
prefetch_related with a source model that uses a UUID primary key.

Backport of bfb5b7150f from master
This commit is contained in:
Brian King
2015-06-05 12:40:51 +01:00
committed by Tim Graham
parent 062ce508b0
commit c58755d875
4 changed files with 119 additions and 1 deletions

View File

@@ -954,7 +954,10 @@ def create_many_related_manager(superclass, rel):
getattr(result, '_prefetch_related_val_%s' % f.attname)
for f in fk.local_related_fields
),
lambda inst: tuple(getattr(inst, f.attname) for f in fk.foreign_related_fields),
lambda inst: tuple(
f.get_db_prep_value(getattr(inst, f.attname), connection)
for f in fk.foreign_related_fields
),
False,
self.prefetch_cache_name,
)