MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / add_mapped_attribute

Function add_mapped_attribute

lib/sqlalchemy/orm/decl_api.py:1023–1039  ·  view source on GitHub ↗

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]
)

Source from the content-addressed store, hash-verified

1021
1022
1023def 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
1042def declarative_base(

Callers 1

test_add_prop_manualMethod · 0.90

Calls 1

_add_attributeFunction · 0.85

Tested by 1

test_add_prop_manualMethod · 0.72