Undocumented
Class |
|
Represents an "aliased" form of a mapped class for usage with Query. |
Class |
|
Provide an inspection interface for an :class:`.AliasedClass` object. |
Class |
|
A grouping of SQL expressions that are returned by a :class:`.Query` under one namespace. |
Class |
|
Keeps track of the options sent to :paramref:`.relationship.cascade` |
Class |
|
Add additional WHERE criteria to the load for all occurrences of a particular entity. |
Class |
|
ColumnAdapter subclass which excludes adaptation of entities from non-matching mappers. |
Class |
|
ColumnAdapter which includes a role attribute. |
Function | has |
Return True if the given object has a database identity. |
Function | identity |
Generate "identity key" tuples, as are used as keys in the :attr:`.Session.identity_map` dictionary. |
Function | polymorphic |
Create a ``UNION`` statement used by a polymorphic mapper. |
Function | was |
Return True if the given object was deleted within a session flush. |
Function | with |
Create filtering criterion that relates this query's primary entity to the given related instance, using established :func:`_orm.relationship()` configuration. |
Variable | all |
Undocumented |
Variable | de |
Undocumented |
Variable | de |
Undocumented |
Variable | eval |
Undocumented |
Variable |
|
Undocumented |
Class | _ |
Undocumented |
Class | _ |
Undocumented |
Class | _ |
Undocumented |
Class | _ |
Extend Join to support ORM constructs as input. |
Class | _ |
Enumeration of all the use cases for ORMAdapter. |
Class | _ |
A wrapper used within the loader_criteria lambda caller so that we can bypass declared_attr descriptors on unmapped mixins, which normally emit a warning for such use. |
Exception | _ |
Undocumented |
Function | _cleanup |
Undocumented |
Function | _entity |
determine if 'given' corresponds to 'entity', in terms of an entity passed to Query that would match the same entity being referred to elsewhere in the query. |
Function | _entity |
determine if 'given' corresponds to 'entity', in terms of a path of loader options where a mapped attribute is taken to be a member of a parent entity. |
Function | _entity |
determine if 'given' "is a" mapper, in terms of the given would load rows of type 'mapper'. |
Function | _extract |
given an annotation, figure out if it's ``Mapped[something]`` and if so, return the ``something`` part. |
Function | _getitem |
calculate __getitem__ in terms of an iterable query object that also has a slice() method. |
Function | _inspect |
Undocumented |
Function | _inspect |
Undocumented |
Function | _is |
Undocumented |
Function | _orm |
Deep copy the given ClauseElement, annotating each element with the "_orm_adapt" flag. |
Function | _orm |
Remove annotations that link a column to a particular mapping. |
Function | _orm |
Undocumented |
Function | _validator |
Runs a validation method on an attribute value to be set or appended. |
Type Variable | _T |
Undocumented |
Variable | _de |
Undocumented |
Return True if the given object has a database identity. This typically corresponds to the object being in either the persistent or detached state. .. seealso:: :func:`.was_deleted`
Optional[ Type[ _T]]
= None, ident: Union[ Any, Tuple[ Any, ...]]
= None, *, instance: Optional[ _T]
= None, row: Optional[ Union[ Row[ Any], RowMapping]]
= None, identity_token: Optional[ Any]
= None) -> _IdentityKeyType[ _T]
:
(source)
¶
Generate "identity key" tuples, as are used as keys in the :attr:`.Session.identity_map` dictionary. This function has several call styles: * ``identity_key(class, ident, identity_token=token)`` This form receives a mapped class and a primary key scalar or tuple as an argument. E.g.:: >>> identity_key(MyClass, (1, 2)) (<class '__main__.MyClass'>, (1, 2), None) :param class: mapped class (must be a positional argument) :param ident: primary key, may be a scalar or tuple argument. :param identity_token: optional identity token .. versionadded:: 1.2 added identity_token * ``identity_key(instance=instance)`` This form will produce the identity key for a given instance. The instance need not be persistent, only that its primary key attributes are populated (else the key will contain ``None`` for those missing values). E.g.:: >>> instance = MyClass(1, 2) >>> identity_key(instance=instance) (<class '__main__.MyClass'>, (1, 2), None) In this form, the given instance is ultimately run though :meth:`_orm.Mapper.identity_key_from_instance`, which will have the effect of performing a database check for the corresponding row if the object is expired. :param instance: object instance (must be given as a keyword arg) * ``identity_key(class, row=row, identity_token=token)`` This form is similar to the class/tuple form, except is passed a database result row as a :class:`.Row` or :class:`.RowMapping` object. E.g.:: >>> row = engine.execute(\ text("select * from table where a=1 and b=2")\ ).first() >>> identity_key(MyClass, row=row) (<class '__main__.MyClass'>, (1, 2), None) :param class: mapped class (must be a positional argument) :param row: :class:`.Row` row returned by a :class:`_engine.CursorResult` (must be given as a keyword arg) :param identity_token: optional identity token .. versionadded:: 1.2 added identity_token
Create a ``UNION`` statement used by a polymorphic mapper. See :ref:`concrete_inheritance` for an example of how this is used. :param table_map: mapping of polymorphic identities to :class:`_schema.Table` objects. :param typecolname: string name of a "discriminator" column, which will be derived from the query, producing the polymorphic identity for each row. If ``None``, no polymorphic discriminator is generated. :param aliasname: name of the :func:`~sqlalchemy.sql.expression.alias()` construct generated. :param cast_nulls: if True, non-existent columns, which are represented as labeled NULLs, will be passed into CAST. This is a legacy behavior that is problematic on some backends such as Oracle - in which case it can be set to False.
Return True if the given object was deleted within a session flush. This is regardless of whether or not the object is persistent or detached. .. seealso:: :attr:`.InstanceState.was_deleted`
object
, prop: attributes.QueryableAttribute[ Any]
, from_entity: Optional[ _EntityType[ Any]]
= None) -> ColumnElement[ bool]
:
(source)
¶
Create filtering criterion that relates this query's primary entity to the given related instance, using established :func:`_orm.relationship()` configuration. E.g.:: stmt = select(Address).where(with_parent(some_user, User.addresses)) The SQL rendered is the same as that rendered when a lazy loader would fire off from the given parent on that attribute, meaning that the appropriate state is taken from the parent object in Python without the need to render joins to the parent table in the rendered statement. The given property may also make use of :meth:`_orm.PropComparator.of_type` to indicate the left side of the criteria:: a1 = aliased(Address) a2 = aliased(Address) stmt = select(a1, a2).where( with_parent(u1, User.addresses.of_type(a2)) ) The above use is equivalent to using the :func:`_orm.with_parent.from_entity` argument:: a1 = aliased(Address) a2 = aliased(Address) stmt = select(a1, a2).where( with_parent(u1, User.addresses, from_entity=a2) ) :param instance: An instance which has some :func:`_orm.relationship`. :param property: Class-bound attribute, which indicates what relationship from the instance should be used to reconcile the parent/child relationship. :param from_entity: Entity in which to consider as the left side. This defaults to the "zero" entity of the :class:`_query.Query` itself. .. versionadded:: 1.2
_InternalEntityType[ Any]
, entity: _InternalEntityType[ Any]
) -> bool
:
(source)
¶
determine if 'given' corresponds to 'entity', in terms of an entity passed to Query that would match the same entity being referred to elsewhere in the query.
_InternalEntityType[ Any]
, entity: _InternalEntityType[ Any]
) -> bool
:
(source)
¶
determine if 'given' corresponds to 'entity', in terms of a path of loader options where a mapped attribute is taken to be a member of a parent entity. e.g.:: someoption(A).someoption(A.b) # -> fn(A, A) -> True someoption(A).someoption(C.d) # -> fn(A, C) -> False a1 = aliased(A) someoption(a1).someoption(A.b) # -> fn(a1, A) -> False someoption(a1).someoption(a1.b) # -> fn(a1, a1) -> True wp = with_polymorphic(A, [A1, A2]) someoption(wp).someoption(A1.foo) # -> fn(wp, A1) -> False someoption(wp).someoption(wp.A1.foo) # -> fn(wp, wp.A1) -> True
Optional[ _AnnotationScanType]
, cls: type
, originating_module: str
, key: str
, attr_cls: Type[ Any]
, required: bool
, is_dataclass_field: bool
, expect_mapped: bool
= True, raiseerr: bool
= True) -> Optional[ Tuple[ Union[ type, str], Optional[ type]]]
:
(source)
¶
given an annotation, figure out if it's ``Mapped[something]`` and if so, return the ``something`` part. Includes error raise scenarios and other options.
def _inspect_generic_alias(class_:
Type[ _O]
) -> Optional[ Mapper[ _O]]
:
(source)
¶
Undocumented
_AnnotationScanType
, cls: Type[ Any]
, originating_cls: Type[ Any]
) -> bool
:
(source)
¶
Undocumented
Deep copy the given ClauseElement, annotating each element with the "_orm_adapt" flag. Elements within the exclude collection will be cloned but not annotated.
Remove annotations that link a column to a particular mapping. Note this doesn't affect "remote" and "foreign" annotations passed by the :func:`_orm.foreign` and :func:`_orm.remote` annotators.