From: Federico Caselli Date: Tue, 12 Jan 2021 21:26:34 +0000 (+0100) Subject: Replace mapper with map_imperatively in mapping styles example X-Git-Tag: rel_1_4_0b2~50^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8dc41b6987c0e405bdf3e7cf4eb221fc1c3cced6;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Replace mapper with map_imperatively in mapping styles example Fixes: #5829 Change-Id: Iad49b038a6061c1b699b31400a199bf65ced6156 --- diff --git a/doc/build/orm/mapping_styles.rst b/doc/build/orm/mapping_styles.rst index d260724d85..3abcafed35 100644 --- a/doc/build/orm/mapping_styles.rst +++ b/doc/build/orm/mapping_styles.rst @@ -525,9 +525,11 @@ on the class itself as declarative class variables:: from sqlalchemy import MetaData from sqlalchemy import String from sqlalchemy import Table - from sqlalchemy.orm import mapper + from sqlalchemy.orm import registry from sqlalchemy.orm import relationship + mapper_registry = registry() + @dataclass class User: id: int = field(init=False) @@ -561,11 +563,11 @@ on the class itself as declarative class variables:: Column('email_address', String(50)), ) - mapper(User, user, properties={ + mapper_registry.map_imperatively(User, user, properties={ 'addresses': relationship(Address, backref='user', order_by=address.c.id), }) - mapper(Address, address) + mapper_registry.map_imperatively(Address, address) .. _orm_mapper_configuration_overview: @@ -583,7 +585,7 @@ There are four general classes of configuration information that the :func:`_orm.mapper` function looks for: The class to be mapped ------------------------ +---------------------- This is a class that we construct in our application. There are generally no restrictions on the structure of this class. [1]_ @@ -628,7 +630,7 @@ class, but does not modify the given :class:`_schema.Table` or other .. _orm_mapping_properties: The properties dictionary --------------------------- +------------------------- This is a dictionary of all of the attributes that will be associated with the mapped class. By default, the @@ -650,7 +652,7 @@ to :meth:`_orm.registry.map_imperatively`, which will pass it along to the :paramref:`_orm.mapper.properties` parameter. Other mapper configuration parameters ---------------------------------------- +------------------------------------- These flags are documented at :func:`_orm.mapper`.