Skip to content
Browse files

Relation._fast_query: Return None for relations that are not found.

  • Loading branch information...
1 parent 62c8f2d commit 6a6201723f6265d0f9818b952e5745eb130964dd @bsimpson63 bsimpson63 committed Feb 24, 2014
Showing with 5 additions and 9 deletions.
  1. +5 −9 r2/r2/lib/db/thing.py
View
14 r2/r2/lib/db/thing.py
@@ -865,19 +865,15 @@ def lookup_rel_ids(pairs):
res = sgm(cls._cache, pairs, lookup_rel_ids, prefix)
# get the relation objects
- id_to_pair = {rel_id: (thing1_dict[thing1_id],
- thing2_dict[thing2_id],
- name)
- for (thing1_id, thing2_id, name), rel_id
- in res.iteritems()
- if rel_id is not None}
- rel_ids = id_to_pair.keys()
+ rel_ids = {rel_id for rel_id in res.itervalues()
+ if rel_id is not None}
rels = cls._byID_rel(rel_ids, data=data, eager_load=eager_load,
thing_data=thing_data)
res_obj = {}
- for rel_id, rel in rels.iteritems():
- pair = id_to_pair[rel_id]
+ for (thing1_id, thing2_id, name), rel_id in res.iteritems():
+ pair = (thing1_dict[thing1_id], thing2_dict[thing2_id], name)
+ rel = rels[rel_id] if rel_id is not None else None
res_obj[pair] = rel
return res_obj

0 comments on commit 6a62017

Please sign in to comment.
Something went wrong with that request. Please try again.