class MapperProperty(HasCacheKey, _DCAttributeOptions, _MappedAttribute[
Known subclasses: sqlalchemy.orm.descriptor_props.DescriptorProperty
, sqlalchemy.orm.interfaces.StrategizedProperty
Represent a particular class attribute mapped by :class:`_orm.Mapper`. The most common occurrences of :class:`.MapperProperty` are the mapped :class:`_schema.Column`, which is represented in a mapping as an instance of :class:`.ColumnProperty`, and a reference to another class produced by :func:`_orm.relationship`, represented in the mapping as an instance of :class:`.Relationship`.
Method | __init__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | cascade |
Iterate through instances related to the given instance for a particular 'cascade', starting with this MapperProperty. |
Method | create |
Produce row processing functions and append to the given set of populators lists. |
Method | do |
Perform subclass-specific initialization post-mapper-creation steps. |
Method | init |
Called after all mappers are created to assemble relationships between mappers and perform other post-mapper-creation initialization steps. |
Method | instrument |
Hook called by the Mapper to the property to initiate instrumentation of the class attribute managed by this MapperProperty. |
Method | merge |
Merge the attribute represented by this ``MapperProperty`` from source to destination object. |
Method | post |
Perform instrumentation adjustments that need to occur after init() has completed. |
Method | set |
Set the parent mapper that references this MapperProperty. |
Method | setup |
Called by Query for the purposes of constructing a SQL statement. |
Class Variable | __slots__ |
Undocumented |
Class Variable | cascade |
Undocumented |
Class Variable | comparator |
The :class:`_orm.PropComparator` instance that implements SQL expression construction on behalf of this mapped attribute. |
Class Variable | doc |
optional documentation string |
Class Variable | info |
Info dictionary associated with the object, allowing user-defined data to be associated with this :class:`.InspectionAttr`. |
Class Variable | is |
Part of the InspectionAttr interface; states this object is a mapper property. |
Class Variable | key |
name of class attribute |
Instance Variable | parent |
the :class:`.Mapper` managing this property. |
Property | class |
Return the class-bound descriptor corresponding to this :class:`.MapperProperty`. |
Method | _memoized |
Info dictionary associated with the object, allowing user-defined data to be associated with this :class:`.InspectionAttr`. |
Class Variable | _cache |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _links |
True if this MapperProperty refers to a mapped entity. |
Instance Variable | _attribute |
behavioral options for ORM-enabled Python attributes |
Instance Variable | _configure |
Undocumented |
Instance Variable | _configure |
Undocumented |
Instance Variable | _has |
Undocumented |
Inherited from HasCacheKey
:
Class Variable | inherit |
Indicate if this :class:`.HasCacheKey` instance should make use of the cache key generation scheme used by its immediate superclass. |
Class Method | _generate |
generate cache key dispatcher for a new class. |
Class Method | _generate |
Undocumented |
Method | _gen |
return an optional cache key. |
Method | _generate |
return a cache key. |
Class Variable | _generated |
Undocumented |
Class Variable | _hierarchy |
private attribute which may be set to False to prevent the inherit_cache warning from being emitted for a hierarchy of subclasses. |
Class Variable | _is |
Undocumented |
Inherited from TypingOnly
(via HasCacheKey
, _DCAttributeOptions
, _MappedAttribute
):
Method | __init |
Undocumented |
Inherited from InspectionAttr
(via HasCacheKey
, _DCAttributeOptions
, _MappedAttribute
, TypingOnly
, InspectionAttrInfo
):
Class Variable | is |
True if this object is an instance of :class:`.AliasedClass`. |
Class Variable | is |
True if this object is a Python :term:`descriptor`. |
Class Variable | is |
True if this object is an instance of :class:`.Bundle`. |
Class Variable | is |
True if this object is an instance of :class:`_expression.ClauseElement`. |
Class Variable | is |
True if this object is an instance of :class:`.InstanceState`. |
Class Variable | is |
True if this object is an instance of :class:`_orm.Mapper`. |
Class Variable | is |
Return True if this object is an instance of :class:`_expression.Selectable`. |
Class Variable | _is |
True if this object is an internal proxy object. |
Inherited from MemoizedSlots
(via HasCacheKey
, _DCAttributeOptions
, _MappedAttribute
, TypingOnly
, InspectionAttrInfo
, InspectionAttr
):
Method | __getattr__ |
Undocumented |
Method | _fallback |
Undocumented |
str
, state: InstanceState[ Any]
, dict_: _InstanceDict
, visited_states: Set[ InstanceState[ Any]]
, halt_on: Optional[ Callable[ [ InstanceState[ Any]], bool]]
= None) -> Iterator[ Tuple[ object, Mapper[ Any], InstanceState[ Any], _InstanceDict]]
:
(source)
¶
sqlalchemy.orm.properties.RelationshipProperty
Iterate through instances related to the given instance for a particular 'cascade', starting with this MapperProperty. Return an iterator3-tuples (instance, mapper, state). Note that the 'cascade' collection on this MapperProperty is checked first for the given type before cascade_iterator is called. This method typically only applies to Relationship.
ORMCompileState
, query_entity: _MapperEntity
, path: AbstractEntityRegistry
, mapper: Mapper[ Any]
, result: Result[ Any]
, adapter: Optional[ ORMAdapter]
, populators: _PopulatorDict
):
(source)
¶
sqlalchemy.orm.interfaces.StrategizedProperty
Produce row processing functions and append to the given set of populators lists.
sqlalchemy.orm.descriptor_props.CompositeProperty
, sqlalchemy.orm.interfaces.StrategizedProperty
Perform subclass-specific initialization post-mapper-creation steps. This is a template method called by the ``MapperProperty`` object's init() method.
Called after all mappers are created to assemble relationships between mappers and perform other post-mapper-creation initialization steps.
sqlalchemy.orm.descriptor_props.DescriptorProperty
, sqlalchemy.orm.properties.ColumnProperty
, sqlalchemy.orm.properties.RelationshipProperty
Hook called by the Mapper to the property to initiate instrumentation of the class attribute managed by this MapperProperty. The MapperProperty here will typically call out to the attributes module to set up an InstrumentedAttribute. This step is the first of two steps to set up an InstrumentedAttribute, and is called early in the mapper setup process. The second step is typically the init_class_attribute step, called from StrategizedProperty via the post_instrument_class() hook. This step assigns additional state to the InstrumentedAttribute (specifically the "impl") which has been determined after the MapperProperty has determined what kind of persistence management it needs to do (e.g. scalar, object, collection, etc).
Session
, source_state: InstanceState[ Any]
, source_dict: _InstanceDict
, dest_state: InstanceState[ Any]
, dest_dict: _InstanceDict
, load: bool
, _recursive: Dict[ Any, object]
, _resolve_conflict_map: Dict[ _IdentityKeyType[ Any], object]
):
(source)
¶
sqlalchemy.orm.properties.ColumnProperty
, sqlalchemy.orm.properties.RelationshipProperty
Merge the attribute represented by this ``MapperProperty`` from source to destination object.
sqlalchemy.orm.interfaces.StrategizedProperty
Perform instrumentation adjustments that need to occur after init() has completed. The given Mapper is the Mapper invoking the operation, which may not be the same Mapper as self.parent in an inheritance scenario; however, Mapper will always at least be a sub-mapper of self.parent. This method is typically used by StrategizedProperty, which delegates it to LoaderStrategy.init_class_attribute() to perform final setup on the class-bound InstrumentedAttribute.
sqlalchemy.orm.descriptor_props.SynonymProperty
Set the parent mapper that references this MapperProperty. This method is overridden by some subclasses to perform extra setup when the mapper is first known.
ORMCompileState
, query_entity: _MapperEntity
, path: AbstractEntityRegistry
, adapter: Optional[ ORMAdapter]
, **kwargs: Any
):
(source)
¶
sqlalchemy.orm.interfaces.StrategizedProperty
Called by Query for the purposes of constructing a SQL statement. Each MapperProperty associated with the target mapper processes the statement referenced by the query context, adding columns and/or criterion as appropriate.
The :class:`_orm.PropComparator` instance that implements SQL expression construction on behalf of this mapped attribute.
sqlalchemy.orm.descriptor_props.DescriptorProperty
, sqlalchemy.orm.properties.ColumnProperty
, sqlalchemy.orm.properties.RelationshipProperty
optional documentation string
Info dictionary associated with the object, allowing user-defined data to be associated with this :class:`.InspectionAttr`. The dictionary is generated when first accessed. Alternatively, it can be specified as a constructor argument to the :func:`.column_property`, :func:`_orm.relationship`, or :func:`.composite` functions. .. versionchanged:: 1.0.0 :attr:`.InspectionAttr.info` moved from :class:`.MapperProperty` so that it can apply to a wider variety of ORM and extension constructs. .. seealso:: :attr:`.QueryableAttribute.info` :attr:`.SchemaItem.info`
sqlalchemy.orm.descriptor_props.SynonymProperty
the :class:`.Mapper` managing this property.
Return the class-bound descriptor corresponding to this :class:`.MapperProperty`. This is basically a ``getattr()`` call:: return getattr(self.parent.class_, self.key) I.e. if this :class:`.MapperProperty` were named ``addresses``, and the class to which it is mapped is ``User``, this sequence is possible:: >>> from sqlalchemy import inspect >>> mapper = inspect(User) >>> addresses_property = mapper.attrs.addresses >>> addresses_property.class_attribute is User.addresses True >>> User.addresses.property is addresses_property True
Info dictionary associated with the object, allowing user-defined data to be associated with this :class:`.InspectionAttr`. The dictionary is generated when first accessed. Alternatively, it can be specified as a constructor argument to the :func:`.column_property`, :func:`_orm.relationship`, or :func:`.composite` functions. .. versionchanged:: 1.0.0 :attr:`.MapperProperty.info` is also available on extension types via the :attr:`.InspectionAttrInfo.info` attribute, so that it can apply to a wider variety of ORM and extension constructs. .. seealso:: :attr:`.QueryableAttribute.info` :attr:`.SchemaItem.info`
sqlalchemy.orm.descriptor_props.DescriptorProperty
, sqlalchemy.orm.properties.ColumnProperty
, sqlalchemy.orm.properties.RelationshipProperty
True if this MapperProperty refers to a mapped entity. Should only be True for Relationship, False for all others.