MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / add_mapped_attribute

Function add_mapped_attribute

lib/sqlalchemy/orm/decl_api.py:975–991  ·  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

973
974
975def 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
994def 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