From 68ee348d36c7df8ccdaf57c3ca6da03e905590bc Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 9 Mar 2009 01:20:29 +0000 Subject: - a forward and complementing backwards reference which are both of the same direction, i.e. ONETOMANY or MANYTOONE, is now detected, and an error message is raised. Saves crazy CircularDependencyErrors later on. --- lib/sqlalchemy/orm/properties.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/orm/properties.py b/lib/sqlalchemy/orm/properties.py index 9c2268e01..3ae0bfbf5 100644 --- a/lib/sqlalchemy/orm/properties.py +++ b/lib/sqlalchemy/orm/properties.py @@ -703,6 +703,10 @@ class RelationProperty(StrategizedProperty): raise sa_exc.ArgumentError("reverse_property %r on relation %s references " "relation %s, which does not reference mapper %s" % (key, self, other, self.parent)) + if self.direction in (ONETOMANY, MANYTOONE) and self.direction == other.direction: + raise sa_exc.ArgumentError("%s and back-reference %s are both of the same direction %r." + " Did you mean to set remote_side on the many-to-one side ?" % (self, other, self.direction)) + def do_init(self): self._get_target() self._process_dependent_arguments() -- cgit v1.2.1