Add a new mapped attribute to an ORM mapped class. E.g.:: add_mapped_attribute(User, "addresses", relationship(Address)) This may be used for ORM mappings that aren't using a declarative metaclass that intercepts attribute set operations. .. versionadded:: 2.0
(
target: Type[_O], key: str, attr: MapperProperty[Any]
)
| 1021 | |
| 1022 | |
| 1023 | def add_mapped_attribute( |
| 1024 | target: Type[_O], key: str, attr: MapperProperty[Any] |
| 1025 | ) -> None: |
| 1026 | """Add a new mapped attribute to an ORM mapped class. |
| 1027 | |
| 1028 | E.g.:: |
| 1029 | |
| 1030 | add_mapped_attribute(User, "addresses", relationship(Address)) |
| 1031 | |
| 1032 | This may be used for ORM mappings that aren't using a declarative |
| 1033 | metaclass that intercepts attribute set operations. |
| 1034 | |
| 1035 | .. versionadded:: 2.0 |
| 1036 | |
| 1037 | |
| 1038 | """ |
| 1039 | _add_attribute(target, key, attr) |
| 1040 | |
| 1041 | |
| 1042 | def declarative_base( |