diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-01-22 16:27:26 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-01-22 17:16:51 -0500 |
| commit | f5eeac3d18892206abcaa30a295d12a799a8fb9b (patch) | |
| tree | 4510849dd349f60138f67d544f5048e13bfd0e2e /lib/sqlalchemy | |
| parent | 4bf97e41b2d18b86fc7c0bba6acd50e2b58a4a70 (diff) | |
| download | sqlalchemy-f5eeac3d18892206abcaa30a295d12a799a8fb9b.tar.gz | |
InstanceState default path is RootRegistry, not tuple
Fixed regression caused in 1.3.13 by :ticket:`5056` where a refactor of the
ORM path registry system made it such that a path could no longer be
compared to an empty tuple, which can occur in a particular kind of joined
eager loading path. The "empty tuple" use case has been resolved so that
the path registry is compared to a path registry in all cases; the
:class:`.PathRegistry` object itself now implements ``__eq__()`` and
``__ne__()`` methods which will take place for all equality comparisons and
continue to succeed in the not anticipated case that a non-
:class:`.PathRegistry` object is compared, while emitting a warning that
this object should not be the subject of the comparison.
Fixes: #5110
Change-Id: I6cab6cd771c131d12b17939b369212f12c6bee16
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/path_registry.py | 19 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/state.py | 2 |
2 files changed, 19 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/path_registry.py b/lib/sqlalchemy/orm/path_registry.py index 2c0847426..59ae082bb 100644 --- a/lib/sqlalchemy/orm/path_registry.py +++ b/lib/sqlalchemy/orm/path_registry.py @@ -65,7 +65,24 @@ class PathRegistry(HasCacheKey): ] def __eq__(self, other): - return other is not None and self.path == other.path + try: + return other is not None and self.path == other.path + except AttributeError: + util.warn( + "Comparison of PathRegistry to %r is not supported" + % (type(other)) + ) + return False + + def __ne__(self, other): + try: + return other is None or self.path != other.path + except AttributeError: + util.warn( + "Comparison of PathRegistry to %r is not supported" + % (type(other)) + ) + return True def set(self, attributes, key, value): log.debug("set '%s' on path '%s' to '%s'", key, self, value) diff --git a/lib/sqlalchemy/orm/state.py b/lib/sqlalchemy/orm/state.py index 830b36770..40f8b197e 100644 --- a/lib/sqlalchemy/orm/state.py +++ b/lib/sqlalchemy/orm/state.py @@ -62,7 +62,7 @@ class InstanceState(interfaces.InspectionAttrInfo): key = None runid = None load_options = util.EMPTY_SET - load_path = () + load_path = PathRegistry.root insert_order = None _strong_obj = None modified = False |
