diff options
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/ext/automap.py | 9 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/relationships.py | 8 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/sqlalchemy/ext/automap.py b/lib/sqlalchemy/ext/automap.py index e20435911..8b75dce7b 100644 --- a/lib/sqlalchemy/ext/automap.py +++ b/lib/sqlalchemy/ext/automap.py @@ -1153,6 +1153,11 @@ def _m2m_relationship( create_backref = backref_name not in referred_cfg.properties + if table in table_to_map_config: + overlaps = "__*" + else: + overlaps = None + if relationship_name not in map_config.properties: if create_backref: backref_obj = generate_relationship( @@ -1163,9 +1168,11 @@ def _m2m_relationship( referred_cls, local_cls, collection_class=collection_class, + overlaps=overlaps, ) else: backref_obj = None + rel = generate_relationship( automap_base, interfaces.MANYTOMANY, @@ -1173,6 +1180,7 @@ def _m2m_relationship( relationship_name, local_cls, referred_cls, + overlaps=overlaps, secondary=table, primaryjoin=and_( fk.column == fk.parent for fk in m2m_const[0].elements @@ -1198,6 +1206,7 @@ def _m2m_relationship( backref_name, referred_cls, local_cls, + overlaps=overlaps, secondary=table, primaryjoin=and_( fk.column == fk.parent for fk in m2m_const[1].elements diff --git a/lib/sqlalchemy/orm/relationships.py b/lib/sqlalchemy/orm/relationships.py index 7882eff70..2224b4902 100644 --- a/lib/sqlalchemy/orm/relationships.py +++ b/lib/sqlalchemy/orm/relationships.py @@ -3427,6 +3427,14 @@ class JoinCondition(object): and pr not in self.prop._reverse_property and pr.key not in self.prop._overlaps and self.prop.key not in pr._overlaps + # note: the "__*" symbol is used internally by + # SQLAlchemy as a general means of supressing the + # overlaps warning for some extension cases, however + # this is not currently + # a publicly supported symbol and may change at + # any time. + and "__*" not in self.prop._overlaps + and "__*" not in pr._overlaps and not self.prop.parent.is_sibling(pr.parent) and not self.prop.mapper.is_sibling(pr.mapper) and not self.prop.parent.is_sibling(pr.mapper) |
