Fixed #12819. Fixed a bug with caching values of nullable 1to1 fields. Thanks, s.angel@twidi.com for the initial patch, and Alex Gaynor for the tests.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12543 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Joseph Kocherhans 2010-02-23 19:24:27 +00:00
parent 3f443363f9
commit 65b451ae3e
3 changed files with 19 additions and 2 deletions

View file

@ -1203,7 +1203,7 @@ def get_cached_row(klass, row, index_start, max_depth=0, cur_depth=0,
# If the base object exists, populate the
# descriptor cache
setattr(obj, f.get_cache_name(), rel_obj)
if f.unique:
if f.unique and rel_obj is not None:
# If the field is unique, populate the
# reverse descriptor cache on the related object
setattr(rel_obj, f.related.get_cache_name(), obj)