Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Relation._fast_query: Return None for relations that are not found.
Browse files Browse the repository at this point in the history
  • Loading branch information
bsimpson63 committed Feb 25, 2014
1 parent 62c8f2d commit 6a62017
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions r2/r2/lib/db/thing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6a62017

Please sign in to comment.