summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-03-31 13:16:04 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-03-31 13:23:53 -0400
commitb99f8cad8d290bfa123742eafa9d381cb7644cd1 (patch)
tree5c5d4f9d4ebaba8e8d1fad7fe4c1d9f34a206693 /lib
parent42185a1f3866bfc8ebffa2a6c724face8a2db5dc (diff)
downloadsqlalchemy-b99f8cad8d290bfa123742eafa9d381cb7644cd1.tar.gz
Expand sibling tests for overlaps warning
Scaled back the warning message added in :ticket:`5171` to not warn for overlapping columns in an inheritance scenario where a particular relationship is local to a subclass and therefore does not represent an overlap. Add errors documentation for the warning and also expand ``util.warn()`` to include a code parameter. Fixes: #6171 Change-Id: Icb1f12d8d645d439ffd2bbb7371c6b00042b6ae3
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/orm/relationships.py9
-rw-r--r--lib/sqlalchemy/util/langhelpers.py5
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/relationships.py b/lib/sqlalchemy/orm/relationships.py
index c1fcc63c1..2ed9d859a 100644
--- a/lib/sqlalchemy/orm/relationships.py
+++ b/lib/sqlalchemy/orm/relationships.py
@@ -364,6 +364,10 @@ class RelationshipProperty(StrategizedProperty):
.. versionadded:: 1.4
+ .. seealso::
+
+ :ref:`error_qzyx` - usage example
+
:param bake_queries=True:
Use the :class:`.BakedQuery` cache to cache the construction of SQL
used in lazy loads. True by default. Set to False if the
@@ -3423,6 +3427,8 @@ class JoinCondition(object):
and self.prop.key 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)
+ and not self.prop.mapper.is_sibling(pr.parent)
and (
self.prop.key != pr.key
or not self.prop.parent.common_parent(pr.parent)
@@ -3453,7 +3459,8 @@ class JoinCondition(object):
"'%s' (copies %s to %s)" % (pr, fr_, to_)
for (pr, fr_) in other_props
),
- )
+ ),
+ code="qzyx",
)
self._track_overlapping_sync_targets[to_][self.prop] = from_
diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py
index 51b9071d5..b31f316fe 100644
--- a/lib/sqlalchemy/util/langhelpers.py
+++ b/lib/sqlalchemy/util/langhelpers.py
@@ -1604,13 +1604,16 @@ class _hash_limit_string(compat.text_type):
return hash(self) == hash(other)
-def warn(msg):
+def warn(msg, code=None):
"""Issue a warning.
If msg is a string, :class:`.exc.SAWarning` is used as
the category.
"""
+ if code:
+ msg = "%s %s" % (msg, exc.SQLAlchemyError(msg, code=code)._code_str())
+
warnings.warn(msg, exc.SAWarning, stacklevel=2)