diff options
| author | Federico Caselli <cfederico87@gmail.com> | 2023-02-05 17:10:59 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2023-02-05 17:10:59 +0000 |
| commit | 7bc7cb32948250db1fb696e61193d5e4ef2be2be (patch) | |
| tree | 8f3617c7fb642c6063ddb6a898bff7cdaf475128 /lib/sqlalchemy | |
| parent | 2459619e751f39a796bb1dd9fe75947dd0961fee (diff) | |
| parent | 188ed2228b3f80ece2d01a77b320de2967cd8f7d (diff) | |
| download | sqlalchemy-7bc7cb32948250db1fb696e61193d5e4ef2be2be.tar.gz | |
Merge "disallow ORM instrumented attributes from reaching dataclasses" into main
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/decl_base.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/decl_base.py b/lib/sqlalchemy/orm/decl_base.py index a858f12cb..9f4930243 100644 --- a/lib/sqlalchemy/orm/decl_base.py +++ b/lib/sqlalchemy/orm/decl_base.py @@ -1060,6 +1060,17 @@ class _ClassScanMapperConfig(_MapperConfig): attr_value, originating_module, ) in self.collected_annotations.items() + if key not in self.collected_attributes + # issue #9226; check for attributes that we've collected + # which are already instrumented, which we would assume + # mean we are in an ORM inheritance mapping and this attribute + # is already mapped on the superclass. Under no circumstance + # should any QueryableAttribute be sent to the dataclass() + # function; anything that's mapped should be Field and + # that's it + or not isinstance( + self.collected_attributes[key], QueryableAttribute + ) ) ] annotations = {} |
