class QueryableAttribute(interfaces._MappedAttribute, interfaces.InspectionAttr, interfaces.PropComparator, traversals.HasCopyInternals, roles.JoinTargetRole, roles.OnClauseRole, sql_base.Immutable, sql_base.MemoizedHasCacheKey):
Known subclasses: sqlalchemy.orm.attributes.Mapped
Base class for :term:`descriptor` objects that intercept
attribute events on behalf of a .MapperProperty
object. The actual .MapperProperty
is accessible
via the .QueryableAttribute.property
attribute.
See Also
.InstrumentedAttribute
.MapperProperty
_orm.Mapper.all_orm_descriptors
_orm.Mapper.attrs
Method | __clause_element__ |
Undocumented |
Method | __getattr__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | __reduce__ |
Undocumented |
Method | __str__ |
Undocumented |
Method | _bulk_update_tuples |
Return setter tuples for a bulk UPDATE. |
Method | _clone |
Undocumented |
Method | adapt_to_entity |
Return a copy of this PropComparator which will use the given .AliasedInsp to produce corresponding expressions. |
Method | and_ |
Add additional criteria to the ON clause that's represented by this relationship attribute. |
Method | get_history |
Undocumented |
Method | hasparent |
Undocumented |
Method | label |
Undocumented |
Method | of_type |
Redefine this object in terms of a polymorphic subclass, _orm.with_polymorphic construct, or _orm.aliased construct. |
Method | operate |
Operate on an argument. |
Method | reverse_operate |
Reverse operate on an argument. |
Class Variable | __visit_name__ |
Undocumented |
Class Variable | _cache_key_traversal |
Undocumented |
Class Variable | is_attribute |
True if this object is a Python :term:`descriptor`. |
Instance Variable | _extra_criteria |
Undocumented |
Instance Variable | _of_type |
Undocumented |
Instance Variable | _parententity |
Undocumented |
Instance Variable | class_ |
Undocumented |
Instance Variable | comparator |
Undocumented |
Instance Variable | impl |
Undocumented |
Instance Variable | key |
Undocumented |
Property | _annotations |
Undocumented |
Property | _entity_namespace |
Undocumented |
Property | _from_objects |
Undocumented |
Property | _impl_uses_objects |
Undocumented |
Property | _supports_population |
Undocumented |
Property | expression |
The SQL expression object represented by this .QueryableAttribute . |
Property | info |
Return the 'info' dictionary for the underlying SQL element. |
Property | parent |
Return an inspection instance representing the parent. |
Property | property |
Return the .MapperProperty associated with this .QueryableAttribute . |
Inherited from _MappedAttribute
:
Class Variable | __slots__ |
Undocumented |
Inherited from InspectionAttr
:
Class Variable | __slots__ |
Undocumented |
Class Variable | _is_internal_proxy |
True if this object is an internal proxy object. |
Class Variable | is_aliased_class |
True if this object is an instance of .AliasedClass . |
Class Variable | is_bundle |
True if this object is an instance of .Bundle . |
Class Variable | is_clause_element |
True if this object is an instance of _expression.ClauseElement . |
Class Variable | is_instance |
True if this object is an instance of .InstanceState . |
Class Variable | is_mapper |
True if this object is an instance of _orm.Mapper . |
Class Variable | is_property |
True if this object is an instance of .MapperProperty . |
Class Variable | is_selectable |
Return True if this object is an instance of _expression.Selectable . |
Inherited from PropComparator
:
Static Method | any_op |
Undocumented |
Static Method | has_op |
Undocumented |
Static Method | of_type_op |
Undocumented |
Method | any |
Return true if this collection contains any member that meets the given criterion. |
Method | has |
Return true if this element references a member which meets the given criterion. |
Class Variable | __slots__ |
Undocumented |
Instance Variable | _adapt_to_entity |
Undocumented |
Instance Variable | prop |
Undocumented |
Property | _parentmapper |
legacy; this is renamed to _parententity to be compatible with QueryableAttribute. |
Property | _propagate_attrs |
Undocumented |
Property | adapter |
Produce a callable that adapts column expressions to suit an aliased version of this comparator. |
Inherited from ColumnOperators
(via PropComparator
):
Method | __add__ |
Implement the + operator. |
Method | __contains__ |
Undocumented |
Method | __div__ |
Implement the / operator. |
Method | __eq__ |
Implement the == operator. |
Method | __ge__ |
Implement the >= operator. |
Method | __getitem__ |
Implement the [] operator. |
Method | __gt__ |
Implement the > operator. |
Method | __le__ |
Implement the <= operator. |
Method | __lshift__ |
implement the << operator. |
Method | __lt__ |
Implement the < operator. |
Method | __mod__ |
Implement the % operator. |
Method | __mul__ |
Implement the * operator. |
Method | __ne__ |
Implement the != operator. |
Method | __neg__ |
Implement the - operator. |
Method | __radd__ |
Implement the + operator in reverse. |
Method | __rdiv__ |
Implement the / operator in reverse. |
Method | __rmod__ |
Implement the % operator in reverse. |
Method | __rmul__ |
Implement the * operator in reverse. |
Method | __rshift__ |
implement the >> operator. |
Method | __rsub__ |
Implement the - operator in reverse. |
Method | __rtruediv__ |
Implement the // operator in reverse. |
Method | __sub__ |
Implement the - operator. |
Method | __truediv__ |
Implement the // operator. |
Method | all_ |
Produce an _expression.all_ clause against the parent object. |
Method | any_ |
Produce an _expression.any_ clause against the parent object. |
Method | asc |
Produce a _expression.asc clause against the parent object. |
Method | between |
Produce a _expression.between clause against the parent object, given the lower and upper range. |
Method | collate |
Produce a _expression.collate clause against the parent object, given the collation string. |
Method | concat |
Implement the 'concat' operator. |
Method | contains |
Implement the 'contains' operator. |
Method | desc |
Produce a _expression.desc clause against the parent object. |
Method | distinct |
Produce a _expression.distinct clause against the parent object. |
Method | endswith |
Implement the 'endswith' operator. |
Method | ilike |
Implement the ilike operator, e.g. case insensitive LIKE. |
Method | in_ |
Implement the in operator. |
Method | is_ |
Implement the IS operator. |
Method | is_distinct_from |
Implement the IS DISTINCT FROM operator. |
Method | is_not |
Implement the IS NOT operator. |
Method | is_not_distinct_from |
Implement the IS NOT DISTINCT FROM operator. |
Method | like |
Implement the like operator. |
Method | match |
Implements a database-specific 'match' operator. |
Method | not_ilike |
implement the NOT ILIKE operator. |
Method | not_in |
implement the NOT IN operator. |
Method | not_like |
implement the NOT LIKE operator. |
Method | nulls_first |
Produce a _expression.nulls_first clause against the parent object. |
Method | nulls_last |
Produce a _expression.nulls_last clause against the parent object. |
Method | regexp_match |
Implements a database-specific 'regexp match' operator. |
Method | regexp_replace |
Implements a database-specific 'regexp replace' operator. |
Method | startswith |
Implement the startswith operator. |
Class Variable | timetuple |
Hack, allows datetime objects to be compared on the LHS. |
Inherited from Operators
(via PropComparator
, ColumnOperators
):
Method | __and__ |
Implement the & operator. |
Method | __invert__ |
Implement the ~ operator. |
Method | __or__ |
Implement the | operator. |
Method | bool_op |
Return a custom boolean operator. |
Method | op |
Produce a generic operator function. |
Inherited from HasCopyInternals
:
Method | _copy_internals |
Reassign internal elements to be clones of themselves. |
Inherited from JoinTargetRole
:
Class Variable | _role_name |
Undocumented |
Inherited from AllowsLambdaRole
(via JoinTargetRole
):
Class Variable | allows_lambda |
Undocumented |
Inherited from UsesInspection
(via JoinTargetRole
):
Class Variable | _post_inspect |
Undocumented |
Class Variable | uses_inspection |
Undocumented |
Inherited from SQLRole
(via JoinTargetRole
, StructuralRole
):
Class Variable | allows_lambda |
Undocumented |
Class Variable | uses_inspection |
Undocumented |
Inherited from OnClauseRole
:
Class Variable | _role_name |
Undocumented |
Inherited from AllowsLambdaRole
(via OnClauseRole
):
Class Variable | allows_lambda |
Undocumented |
Inherited from SQLRole
(via OnClauseRole
, StructuralRole
):
Class Variable | allows_lambda |
Undocumented |
Class Variable | uses_inspection |
Undocumented |
Inherited from Immutable
:
Method | _copy_internals |
Undocumented |
Method | params |
Undocumented |
Method | unique_params |
Undocumented |
Class Variable | _is_immutable |
Undocumented |
Inherited from MemoizedHasCacheKey
:
Method | _generate_cache_key |
return a cache key. |
Inherited from HasCacheKey
(via MemoizedHasCacheKey
):
Class Variable | inherit_cache |
Indicate if this .HasCacheKey instance should make use of the cache key generation scheme used by its immediate superclass. |
Class Method | _generate_cache_attrs |
generate cache key dispatcher for a new class. |
Class Method | _generate_cache_key_for_object |
Undocumented |
Method | _gen_cache_key |
return an optional cache key. |
Class Variable | __slots__ |
Undocumented |
Class Variable | _hierarchy_supports_caching |
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_has_cache_key |
Undocumented |
Undocumented
.AliasedInsp
to produce corresponding expressions.Add additional criteria to the ON clause that's represented by this relationship attribute.
E.g.:
stmt = select(User).join( User.addresses.and_(Address.email_address != 'foo') ) stmt = select(User).options( joinedload(User.addresses.and_(Address.email_address != 'foo')) )
Redefine this object in terms of a polymorphic subclass,
_orm.with_polymorphic
construct, or _orm.aliased
construct.
Returns a new PropComparator from which further criterion can be evaluated.
e.g.:
query.join(Company.employees.of_type(Engineer)).\ filter(Engineer.name=='foo')
See Also
:ref:`queryguide_join_onclause` - in the :ref:`queryguide_toplevel`
Parameters | |
entity | Undocumented |
class_ | a class or mapper indicating that criterion will be against this specific subclass. |
Operate on an argument.
This is the lowest level of operation, raises
NotImplementedError
by default.
Overriding this on a subclass can allow common
behavior to be applied to all operations.
For example, overriding .ColumnOperators
to apply func.lower() to the left and right
side:
class MyComparator(ColumnOperators): def operate(self, op, other): return op(func.lower(self), func.lower(other))
Parameters | |
op | Operator callable. |
*other | the 'other' side of the operation. Will be a single scalar for most operations. |
**kwargs | modifiers. These may be passed by special
operators such as ColumnOperators.contains . |
Reverse operate on an argument.
Usage is the same as operate
.
bool
=
True if this object is a Python :term:`descriptor`.
This can refer to one of many types. Usually a
.QueryableAttribute
which handles attributes events on behalf
of a .MapperProperty
. But can also be an extension type
such as .AssociationProxy
or .hybrid_property
.
The .InspectionAttr.extension_type
will refer to a constant
identifying the specific subtype.
See Also
_orm.Mapper.all_orm_descriptors
The SQL expression object represented by this
.QueryableAttribute
.
This will typically be an instance of a _sql.ColumnElement
subclass representing a column expression.
Return the 'info' dictionary for the underlying SQL element.
The behavior here is as follows:
.ColumnProperty
, which is mapped directly
to a schema-level _schema.Column
object, this attribute
will return the .SchemaItem.info
dictionary associated
with the core-level _schema.Column
object..ColumnProperty
but is mapped to
any other kind of SQL expression other than a
_schema.Column
,
the attribute will refer to the .MapperProperty.info
dictionary associated directly with the .ColumnProperty
,
assuming the SQL expression itself does not have its own .info
attribute (which should be the case, unless a user-defined SQL
construct has defined one)..MapperProperty
, including .RelationshipProperty
,
the attribute will refer to the .MapperProperty.info
dictionary associated with that .MapperProperty
..MapperProperty.info
dictionary of the
.MapperProperty
unconditionally, including for a
.ColumnProperty
that's associated directly with a
_schema.Column
, the attribute can be referred to using
.QueryableAttribute.property
attribute, as
MyClass.someattribute.property.info.See Also
.SchemaItem.info
.MapperProperty.info
Return an inspection instance representing the parent.
This will be either an instance of _orm.Mapper
or .AliasedInsp
, depending upon the nature
of the parent entity which this attribute is associated
with.