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]
)
| 973 | |
| 974 | |
| 975 | def add_mapped_attribute( |
| 976 | target: Type[_O], key: str, attr: MapperProperty[Any] |
| 977 | ) -> None: |
| 978 | """Add a new mapped attribute to an ORM mapped class. |
| 979 | |
| 980 | E.g.:: |
| 981 | |
| 982 | add_mapped_attribute(User, "addresses", relationship(Address)) |
| 983 | |
| 984 | This may be used for ORM mappings that aren't using a declarative |
| 985 | metaclass that intercepts attribute set operations. |
| 986 | |
| 987 | .. versionadded:: 2.0 |
| 988 | |
| 989 | |
| 990 | """ |
| 991 | _add_attribute(target, key, attr) |
| 992 | |
| 993 | |
| 994 | def declarative_base( |