diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-03-09 01:20:29 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-03-09 01:20:29 +0000 |
commit | 68ee348d36c7df8ccdaf57c3ca6da03e905590bc (patch) | |
tree | 5e41f655301528ab2bcb64c08aa5c9294f77c1c2 /lib/sqlalchemy | |
parent | 1b5d224df5e9393e7a8a89c7b29c08d189e89685 (diff) | |
download | sqlalchemy-68ee348d36c7df8ccdaf57c3ca6da03e905590bc.tar.gz |
- 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.
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r-- | lib/sqlalchemy/orm/properties.py | 4 |
1 files changed, 4 insertions, 0 deletions
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() |