diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-11-28 10:58:49 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-11-28 12:01:48 -0500 |
commit | 0c50f8dfdeb8adf997cbc8aa03443e8e47761cb3 (patch) | |
tree | 92c235fab367a2ea30943f2e6624ef7f4923f3ea /lib/sqlalchemy/orm/util.py | |
parent | db2344b0a2a9ef164651d645a8da2d7a9d1bc250 (diff) | |
download | sqlalchemy-0c50f8dfdeb8adf997cbc8aa03443e8e47761cb3.tar.gz |
identify unresolvable Mapped types
Fixed issue where use of an unknown datatype within a :class:`.Mapped`
annotation for a column-based attribute would silently fail to map the
attribute, rather than reporting an exception; an informative exception
message is now raised.
tighten up iteration of names on mapped classes to more fully
exclude a large number of underscored names, so that we can avoid trying
to look at annotations for them or anything else. centralize the
"list of names we care about" more fully within _cls_attr_resolver
and base it on underscore conventions we should usually ignore,
with the exception of the few underscore names we want to see.
Fixes: #8888
Change-Id: I3c0a1666579fe67b3c40cc74fa443b6f1de354ce
Diffstat (limited to 'lib/sqlalchemy/orm/util.py')
-rw-r--r-- | lib/sqlalchemy/orm/util.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py index 6250cd104..58407a74d 100644 --- a/lib/sqlalchemy/orm/util.py +++ b/lib/sqlalchemy/orm/util.py @@ -2033,6 +2033,12 @@ def _is_mapped_annotation( cls, raw_annotation, originating_cls.__module__ ) except NameError: + # in most cases, at least within our own tests, we can raise + # here, which is more accurate as it prevents us from returning + # false negatives. However, in the real world, try to avoid getting + # involved with end-user annotations that have nothing to do with us. + # see issue #8888 where we bypass using this function in the case + # that we want to detect an unresolvable Mapped[] type. return False else: return is_origin_of_cls(annotated, _MappedAnnotationBase) |