Some key internal constructs are listed here.
Bases: dict
tracks state information at the class level.
Dissasociate this manager from its class.
TODO
Mark this instance as the manager for its class.
x.__init__(...) initializes x; see help(type(x)) for signature
Return a (instance) -> InstanceState callable.
“state getter” callables should raise either KeyError or AttributeError if no InstanceState could be found for the instance.
remove all instrumentation established by this ClassManager.
Bases: sqlalchemy.orm.interfaces.StrategizedProperty
Describes an object attribute that corresponds to a table column.
Construct a ColumnProperty.
Parameters: |
|
---|
Bases: sqlalchemy.orm.descriptor_props.DescriptorProperty
Initialization which occurs after the CompositeProperty has been associated with its parent mapper.
Provided for userland code that uses attributes.get_history().
Bases: object
tracks state information at the instance level.
Commit attributes.
This is used by a partial-attribute load operation to mark committed those attributes which were refreshed from the database.
Attributes marked as “expired” can potentially remain “expired” after this step if a value was not populated in state.dict.
commit all attributes unconditionally.
This is used after a flush() or a full load/refresh to remove all pending state from the instance.
- all attributes are marked as “committed”
- the “strong dirty reference” is removed
- the “modified” flag is set to False
- any “expired” markers/callables for attributes loaded are removed.
Attributes marked as “expired” can potentially remain “expired” after this step if a value was not populated in state.dict.
a fast expire that can be called by column loaders during a load.
The additional bookkeeping is finished up in commit_all().
This method is actually called a lot with joined-table loading, when the second table isn’t present in the result.
Return the set of keys which are ‘expired’ to be loaded by the manager’s deferred scalar loader, assuming no pending changes.
see also the unmodified collection which is intersected against this set when a refresh operation occurs.
Set this attribute to an empty value or collection, based on the AttributeImpl in use.
Remove the given attribute and any callables associated with it.
Remove the given attribute and set the given callable as a loader.
Return the set of keys which do not have a loaded value.
This includes expired attributes and any other attribute that was never populated or modified.
Return the set of keys which have no uncommitted changes
Return self.unmodified.intersection(keys).
Return a list of tuples (state, obj) for the given key.
returns an empty list if the value is None/empty/PASSIVE_NO_RESULT
Bases: object
Manage the relationship of a Mapper to a single class attribute, as well as that attribute as it appears on individual instances of the class, including attribute instrumentation, attribute access, loading behavior, and dependency calculations.
The set of ‘cascade’ attribute names.
This collection is checked before the ‘cascade_iterator’ method is called.
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.
See PropertyLoader for the related instance implementation.
Return the class-bound descriptor corresponding to this MapperProperty.
Return a compare operation for the columns represented by this MapperProperty to the given value, which may be a column value or an instance. ‘operator’ is an operator from the operators module, or from sql.Comparator.
By default uses the PropComparator attached to this MapperProperty under the attribute name “comparator”.
Return a 3-tuple consisting of three row processing functions.
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.
Return True if this MapperProperty‘s mapper is the primary mapper for its class.
This flag is used to indicate that the MapperProperty can define attribute instrumentation for the class at the class level (as opposed to the individual instance level).
Merge the attribute represented by this MapperProperty from source to destination object
Perform instrumentation adjustments that need to occur after init() has completed.
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.
Bases: sqlalchemy.sql.expression.ColumnOperators
Defines comparison operations for MapperProperty objects.
User-defined subclasses of PropComparator may be created. The built-in Python comparison and math operator methods, such as __eq__(), __lt__(), __add__(), can be overridden to provide new operator behaivor. The custom PropComparator is passed to the mapper property via the comparator_factory argument. In each case, the appropriate subclass of PropComparator should be used:
from sqlalchemy.orm.properties import \
ColumnProperty,\
CompositeProperty,\
RelationshipProperty
class MyColumnComparator(ColumnProperty.Comparator):
pass
class MyCompositeComparator(CompositeProperty.Comparator):
pass
class MyRelationshipComparator(RelationshipProperty.Comparator):
pass
Return a copy of this PropComparator which will use the given adaption function on the local side of generated expressions.
Return true if this collection contains any member that meets the given criterion.
Return true if this element references a member which meets the given criterion.
Redefine this object in terms of a polymorphic subclass.
Returns a new PropComparator from which further criterion can be evaluated.
e.g.:
query.join(Company.employees.of_type(Engineer)).\
filter(Engineer.name=='foo')
Bases: sqlalchemy.orm.interfaces.StrategizedProperty
Describes an object property that holds a single item or list of items that correspond to a related database table.