Skip to content
This repository has been archived by the owner on Jan 18, 2020. It is now read-only.

Commit

Permalink
Check for redundant targets for symmetrical routes
Browse files Browse the repository at this point in the history
Signed-off-by: Byron Ruth <b@devel.io>
  • Loading branch information
bruth committed Nov 11, 2014
1 parent d0bf12b commit 75309ac
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions modeltree/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,9 +528,9 @@ def _build_routes(self, routes, allow_redundant_targets=True):

if not allow_redundant_targets:
if target in targets_seen:
tpl = ('Model {0} cannot be the target of more than one '
'route in this list')
raise ValueError(tpl.format(target_label))
raise ValueError('Model {0} cannot be the target of '
'more than one route in this list'
.format(target_label))
else:
targets_seen.add(target)

Expand All @@ -539,7 +539,16 @@ def _build_routes(self, routes, allow_redundant_targets=True):
# join field is implied or does not matter; the route is reduced
# to a straight lookup.
joins[(source, target)] = field

if symmetrical:
if not allow_redundant_targets:
if source in targets_seen:
raise ValueError('Model {0} cannot be the target of '
'more than one route in this list'
.format(source_label))
else:
targets_seen.add(source)

joins[(target, source)] = field

return joins
Expand Down

0 comments on commit 75309ac

Please sign in to comment.