diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-03-18 10:33:40 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-03-18 10:34:25 -0400 |
| commit | 764e36e5e7b7faf1a97b4b06be1ca307ac4fce46 (patch) | |
| tree | adba2531d36e4f5f2f9d910fa3364def4c69624c /lib/sqlalchemy/ext | |
| parent | c2fe4a264003933ff895c51f5d07a8456ac86382 (diff) | |
| download | sqlalchemy-764e36e5e7b7faf1a97b4b06be1ca307ac4fce46.tar.gz | |
catch unexpected errors when accessing clslevel attribute
Improved the error message that's raised for the case where the
:func:`.association_proxy` construct attempts to access a target attribute
at the class level, and this access fails. The particular use case here is
when proxying to a hybrid attribute that does not include a working
class-level implementation.
Fixes: #7827
Change-Id: Ic6ff9df010f49253e664a1e7c7e16d8546006965
Diffstat (limited to 'lib/sqlalchemy/ext')
| -rw-r--r-- | lib/sqlalchemy/ext/associationproxy.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/sqlalchemy/ext/associationproxy.py b/lib/sqlalchemy/ext/associationproxy.py index 4d2b1d8b6..194eabb64 100644 --- a/lib/sqlalchemy/ext/associationproxy.py +++ b/lib/sqlalchemy/ext/associationproxy.py @@ -583,6 +583,13 @@ class AssociationProxyInstance(SQLORMOperations[_T]): return AmbiguousAssociationProxyInstance( parent, owning_class, target_class, value_attr ) + except Exception as err: + raise exc.InvalidRequestError( + f"Association proxy received an unexpected error when " + f"trying to retreive attribute " + f'"{target_class.__name__}.{parent.value_attr}" from ' + f'class "{target_class.__name__}": {err}' + ) from err else: return cls._construct_for_assoc( target_assoc, parent, owning_class, target_class, value_attr |
