L i:@UdZddlmZddlmZddlmZddlmZddl Z ddl Z ddl m Z ddl m Z dd l mZdd l mZdd l mZdd l mZdd l mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl Z ddl!m"Z"ddl!m#Z$ddl!m%Z%ddl!m&Z&dd l!m'Z'dd!l!m(Z)dd"l*m+Z+dd#l,m-Z-dd$l,m.Z.dd%l,m/Z/dd&l,m0Z0dd'l,m1Z1dd(l2m3Z3dd)l2m4Z4dd*l2m5Z5dd+l2m6Z6dd,l2m7Z7dd-l2m8Z8dd.l2m9Z9dd/l:m;Z;d0d1l!mZ>d0d3l!m?Z?d0d4l!m@Z@d0d5l!mAZAd0d!l!m(Z(d0d6llAmKZKd0d?lLmMZMd0d@lNmOZOd0dAlPmQZQd0dBlPmRZRd0dClSmTZTd0dDl(mUZUd0dEl(mVZVd0dFlWmXZXerddGl*mYZYddHl*mZZZddIl*m[Z[ddJl*m\Z\ddKl]m^Z^ddLl_m`Z`ddMlambZbddNlamcZcddOldmeZeddPl%mfZfddQl:mgZgddRl'mhZhddSlimjZjddTlkmlZlddUl(mmZmd0dVlnmoZod0dWlnmpZpd0dXlqmrZrd0dYlqmsZsd0dZltmuZud0d[lNmvZvd0d\lNmwZwd0d]lSmxZxd0d^l(myZyed_e `Zzedadb`Z{edcdd`Z|eeXdeeeeXdeeedfee ffedgfeedfee ffZ}e jZdhedi<ddjZddkZdlae(jdmZe j Ze>je?jGdndoe8e7e+eMe5e?je>jdpeCee+ ZGdqdreZddsZ ddtZe(j"du ddvZe(j"duddwZddxZdldydz dd{Zd|Zd}ZGd~dedZy)a5Logic to map Python classes to and from selectables. Defines the :class:`~sqlalchemy.orm.mapper.Mapper` class, the central configurational unit which associates a class with a database table. This is a semi-private module; the main configurational API of the ORM is available in :class:`~sqlalchemy.orm.`. ) annotations)deque)reduce)chainN)Any)Callable)cast) Collection)Deque)Dict) FrozenSet)Generic)Iterable)Iterator)List)Mapping)Optional)Sequence)Set)Tuple)Type) TYPE_CHECKING)TypeVar)Union) attributes)exc)instrumentation)loading) properties)util)_O)_class_to_mapper)_parse_mapper_argument) _state_mapper) PassiveFlag) state_str)_MappedAttribute)EXT_SKIP)InspectionAttr)MapperProperty)ORMEntityColumnsClauseRole)ORMFromClauseRole)StrategizedProperty) PathRegistry)event) inspection)log)schema)sql) dispatcher) EventTarget)base) coercions) expression) operators)roles) TableClause)visitors)MemoizedHasCacheKey)KeyedColumnElement)Column)Table)LABEL_STYLE_TABLENAME_PLUS_COL) HasMemoized)!HasMemoized_ro_memoized_attribute)Literal)_IdentityKeyType) _InstanceDict)_ORMColumnExprArgument) _RegistryType)registry)DependencyProcessor)CompositeProperty)SynonymProperty) MapperEvents) ClassManager)CachingEntityRegistry)ColumnProperty)RelationshipProperty) InstanceState) ORMAdapter)Row) RowMapping)_ColumnExpressionArgument)_EquivalentColumnMap)ReadOnlyColumnCollection) ColumnClause) ColumnElement) FromClause) OrderedSet_T)bound_MPMapperProperty[Any]_FnzCallable[..., Any]* Mapper[Any]r]z.weakref.WeakKeyDictionary[_RegistryType, bool]_mapper_registriescXt5ttcdddS#1swYyxYwN)_CONFIGURE_MUTEXsetrf[/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sqlalchemy/orm/mapper.py_all_registriesrns# '%&'''s )c#^KtD]}|jEd{y7wrh)rn_mappers_to_configure)regs rm_unconfigured_mappersrrs- /,,.../.s !-+-F NO_ATTRIBUTEc:eZdZUdZded<dZdZded<dZejd d ddZ dZ d Z d Z dZd!ed"<edd#Zed$Zd ed < d ed%<d&ed'<d(ed)<d*ed+<d,ed-<d.ed/<ded0<d1ed2<d3ed4<d5ed6<d7ed8<d9ed:<d;ed<<d=ed><d?ed@< dAedB< ded<ded<dCed<dDed<ded<dEed < dEedF< dGed< dHed<dZdedI< ded< dJed< dKedL< dedM< ded< dNed< dOedP< ded< dQedR< dSedT< dSedU< ej&ej(dVdWdXZej,ddYZdZZ dd[Zd\Zd]Zd^Zd_Zdd`ZddaZddbZ ddcZ!dddZ"d Z#e$jJdeZ&e$jJdfZ'e$jJdgZ(ejRdhdiZ*ejRdhd d ddj ddkZ+ ddlZ, d ddmZ-ejRdh ddnZ.ej^jadoe1jdddpZ3ddqZ4drZ5 ddsZ6ddtZ7edduZ8ddvZ9ddwZ:ddxZ;ddyZ d dd|Z? dd}Z@ed~ZA ddZB ddZCe$jJddZDe$jJdZEe$jJdZFe$jJdZGe$jJddZHe$jJdZIeJddZKeHZL eJdZMe$jJdZNe$jJdZOe$jJdZPe$jJdZQe$jJ ddZRe$jJ ddZSe$jJddZTe$jJ ddZUe$jJddZVe$jdZXej,dZYeddZZ d ddZ[e$jJdZ\edZ]ddZ^e$jJddZ_ddZ`e$jJddZae$jJddZbe$jJejRdhddZce$jJejRdhddZdedZee$jJddZfe$jJejRd ddZge$jJejRdhddZh ddZie$jJdZje$jJddZkddZle$jJdZmdZnddZoddZp ddZqddZrddZse$jJddZtddZuddZveddZwddZx d ddZy d ddZzddZ{e|jf ddZ~ddZe$jJdZe$jJdZe$jJdZe$jJdZe$jJdZe|jf ddZdZdZdZe|jfd„ZdÄZdĄZe$jJdńZdƄZdDŽZejRdȫdɄZe$jJdʄZ d dd˄Ze$jJd̄Ze$jJd̈́Ze$jJd΄ZddτZej,dЄZy (MapperaDefines an association between a Python class and a database table or other relational structure, so that ORM operations against the class may proceed. The :class:`_orm.Mapper` object is instantiated using mapping methods present on the :class:`_orm.registry` object. For information about instantiating new :class:`_orm.Mapper` objects, see :ref:`orm_mapping_classes_toplevel`. zdispatcher[Mapper[_O]]dispatchFr_configure_failed)1.3aThe :paramref:`.mapper.non_primary` parameter is deprecated, and will be removed in a future release. The functionality of non primary mappers is now better suited using the :class:`.AliasedClass` construct, which can also be used as the target of a :func:`_orm.relationship` in 1.3.) non_primaryNTclass_Type[_O] local_table primary_keyryboolinheritsinherit_conditionalways_refreshversion_id_colversion_id_generator5Optional[Union[Literal[False], Callable[[Any], Any]]]polymorphic_onpolymorphic_identity Optional[Any]concretewith_polymorphicallow_partial_pks Optional[str]cvtj|td|_|jjd|jj |_tj||_||_ | |_ t| tr| |_ d|_n/| &tj t"j$| dnd|_| durd|_n| d|_n| |_||_d|_|t-||_nd|_|-tj t"j0|dd |_n\|j.r#|j.j2|_d|_n-t5j6d |jj d |*tj t"j8||_nd|_||_|r t?|ni|_ g|_!||_"||_#||_$| &tj t"j$| d nd|_%||_&g|_'tjP|_)||_*||_+||_,d|_-d|_.d|_/i|_0||_1d|_2||_3|j.r|j(sd|_4n||_4|jk|||_6||_7| i|_8n| |_8|tjr||_:nd|_:|rtjr||_;nd|_;tx5t{d|j|j~j|||j|j|j|j|j|jj||jd|jddd|j|j||jy#1swY0xYw)abYDirect constructor for a new :class:`_orm.Mapper` object. The :class:`_orm.Mapper` constructor is not called directly, and is normally invoked through the use of the :class:`_orm.registry` object through either the :ref:`Declarative ` or :ref:`Imperative ` mapping styles. .. versionchanged:: 2.0 The public facing ``mapper()`` function is removed; for a classical mapping configuration, use the :meth:`_orm.registry.map_imperatively` method. Parameters documented below may be passed to either the :meth:`_orm.registry.map_imperatively` method, or may be passed in the ``__mapper_args__`` declarative class attribute described at :ref:`orm_declarative_mapper_options`. :param class\_: The class to be mapped. When using Declarative, this argument is automatically passed as the declared class itself. :param local_table: The :class:`_schema.Table` or other :class:`_sql.FromClause` (i.e. selectable) to which the class is mapped. May be ``None`` if this mapper inherits from another mapper using single-table inheritance. When using Declarative, this argument is automatically passed by the extension, based on what is configured via the :attr:`_orm.DeclarativeBase.__table__` attribute or via the :class:`_schema.Table` produced as a result of the :attr:`_orm.DeclarativeBase.__tablename__` attribute being present. :param polymorphic_abstract: Indicates this class will be mapped in a polymorphic hierarchy, but not directly instantiated. The class is mapped normally, except that it has no requirement for a :paramref:`_orm.Mapper.polymorphic_identity` within an inheritance hierarchy. The class however must be part of a polymorphic inheritance scheme which uses :paramref:`_orm.Mapper.polymorphic_on` at the base. .. versionadded:: 2.0 .. seealso:: :ref:`orm_inheritance_abstract_poly` :param always_refresh: If True, all query operations for this mapped class will overwrite all data within object instances that already exist within the session, erasing any in-memory changes with whatever information was loaded from the database. Usage of this flag is highly discouraged; as an alternative, see the method :meth:`_query.Query.populate_existing`. :param allow_partial_pks: Defaults to True. Indicates that a composite primary key with some NULL values should be considered as possibly existing within the database. This affects whether a mapper will assign an incoming row to an existing identity, as well as if :meth:`.Session.merge` will check the database first for a particular primary key value. A "partial primary key" can occur if one has mapped to an OUTER JOIN, for example. The :paramref:`.orm.Mapper.allow_partial_pks` parameter also indicates to the ORM relationship lazy loader, when loading a many-to-one related object, if a composite primary key that has partial NULL values should result in an attempt to load from the database, or if a load attempt is not necessary. .. versionadded:: 2.0.36 :paramref:`.orm.Mapper.allow_partial_pks` is consulted by the relationship lazy loader strategy, such that when set to False, a SELECT for a composite primary key that has partial NULL values will not be emitted. :param batch: Defaults to ``True``, indicating that save operations of multiple entities can be batched together for efficiency. Setting to False indicates that an instance will be fully saved before saving the next instance. This is used in the extremely rare case that a :class:`.MapperEvents` listener requires being called in between individual row persistence operations. :param column_prefix: A string which will be prepended to the mapped attribute name when :class:`_schema.Column` objects are automatically assigned as attributes to the mapped class. Does not affect :class:`.Column` objects that are mapped explicitly in the :paramref:`.Mapper.properties` dictionary. This parameter is typically useful with imperative mappings that keep the :class:`.Table` object separate. Below, assuming the ``user_table`` :class:`.Table` object has columns named ``user_id``, ``user_name``, and ``password``:: class User(Base): __table__ = user_table __mapper_args__ = {"column_prefix": "_"} The above mapping will assign the ``user_id``, ``user_name``, and ``password`` columns to attributes named ``_user_id``, ``_user_name``, and ``_password`` on the mapped ``User`` class. The :paramref:`.Mapper.column_prefix` parameter is uncommon in modern use. For dealing with reflected tables, a more flexible approach to automating a naming scheme is to intercept the :class:`.Column` objects as they are reflected; see the section :ref:`mapper_automated_reflection_schemes` for notes on this usage pattern. :param concrete: If True, indicates this mapper should use concrete table inheritance with its parent mapper. See the section :ref:`concrete_inheritance` for an example. :param confirm_deleted_rows: defaults to True; when a DELETE occurs of one more rows based on specific primary keys, a warning is emitted when the number of rows matched does not equal the number of rows expected. This parameter may be set to False to handle the case where database ON DELETE CASCADE rules may be deleting some of those rows automatically. The warning may be changed to an exception in a future release. :param eager_defaults: if True, the ORM will immediately fetch the value of server-generated default values after an INSERT or UPDATE, rather than leaving them as expired to be fetched on next access. This can be used for event schemes where the server-generated values are needed immediately before the flush completes. The fetch of values occurs either by using ``RETURNING`` inline with the ``INSERT`` or ``UPDATE`` statement, or by adding an additional ``SELECT`` statement subsequent to the ``INSERT`` or ``UPDATE``, if the backend does not support ``RETURNING``. The use of ``RETURNING`` is extremely performant in particular for ``INSERT`` statements where SQLAlchemy can take advantage of :ref:`insertmanyvalues `, whereas the use of an additional ``SELECT`` is relatively poor performing, adding additional SQL round trips which would be unnecessary if these new attributes are not to be accessed in any case. For this reason, :paramref:`.Mapper.eager_defaults` defaults to the string value ``"auto"``, which indicates that server defaults for INSERT should be fetched using ``RETURNING`` if the backing database supports it and if the dialect in use supports "insertmanyreturning" for an INSERT statement. If the backing database does not support ``RETURNING`` or "insertmanyreturning" is not available, server defaults will not be fetched. .. versionchanged:: 2.0.0rc1 added the "auto" option for :paramref:`.Mapper.eager_defaults` .. seealso:: :ref:`orm_server_defaults` .. versionchanged:: 2.0.0 RETURNING now works with multiple rows INSERTed at once using the :ref:`insertmanyvalues ` feature, which among other things allows the :paramref:`.Mapper.eager_defaults` feature to be very performant on supporting backends. :param exclude_properties: A list or set of string column names to be excluded from mapping. .. seealso:: :ref:`include_exclude_cols` :param include_properties: An inclusive list or set of string column names to map. .. seealso:: :ref:`include_exclude_cols` :param inherits: A mapped class or the corresponding :class:`_orm.Mapper` of one indicating a superclass to which this :class:`_orm.Mapper` should *inherit* from. The mapped class here must be a subclass of the other mapper's class. When using Declarative, this argument is passed automatically as a result of the natural class hierarchy of the declared classes. .. seealso:: :ref:`inheritance_toplevel` :param inherit_condition: For joined table inheritance, a SQL expression which will define how the two tables are joined; defaults to a natural join between the two tables. :param inherit_foreign_keys: When ``inherit_condition`` is used and the columns present are missing a :class:`_schema.ForeignKey` configuration, this parameter can be used to specify which columns are "foreign". In most cases can be left as ``None``. :param legacy_is_orphan: Boolean, defaults to ``False``. When ``True``, specifies that "legacy" orphan consideration is to be applied to objects mapped by this mapper, which means that a pending (that is, not persistent) object is auto-expunged from an owning :class:`.Session` only when it is de-associated from *all* parents that specify a ``delete-orphan`` cascade towards this mapper. The new default behavior is that the object is auto-expunged when it is de-associated with *any* of its parents that specify ``delete-orphan`` cascade. This behavior is more consistent with that of a persistent object, and allows behavior to be consistent in more scenarios independently of whether or not an orphan object has been flushed yet or not. See the change note and example at :ref:`legacy_is_orphan_addition` for more detail on this change. :param non_primary: Specify that this :class:`_orm.Mapper` is in addition to the "primary" mapper, that is, the one used for persistence. The :class:`_orm.Mapper` created here may be used for ad-hoc mapping of the class to an alternate selectable, for loading only. .. seealso:: :ref:`relationship_aliased_class` - the new pattern that removes the need for the :paramref:`_orm.Mapper.non_primary` flag. :param passive_deletes: Indicates DELETE behavior of foreign key columns when a joined-table inheritance entity is being deleted. Defaults to ``False`` for a base mapper; for an inheriting mapper, defaults to ``False`` unless the value is set to ``True`` on the superclass mapper. When ``True``, it is assumed that ON DELETE CASCADE is configured on the foreign key relationships that link this mapper's table to its superclass table, so that when the unit of work attempts to delete the entity, it need only emit a DELETE statement for the superclass table, and not this table. When ``False``, a DELETE statement is emitted for this mapper's table individually. If the primary key attributes local to this table are unloaded, then a SELECT must be emitted in order to validate these attributes; note that the primary key columns of a joined-table subclass are not part of the "primary key" of the object as a whole. Note that a value of ``True`` is **always** forced onto the subclass mappers; that is, it's not possible for a superclass to specify passive_deletes without this taking effect for all subclass mappers. .. seealso:: :ref:`passive_deletes` - description of similar feature as used with :func:`_orm.relationship` :paramref:`.mapper.passive_updates` - supporting ON UPDATE CASCADE for joined-table inheritance mappers :param passive_updates: Indicates UPDATE behavior of foreign key columns when a primary key column changes on a joined-table inheritance mapping. Defaults to ``True``. When True, it is assumed that ON UPDATE CASCADE is configured on the foreign key in the database, and that the database will handle propagation of an UPDATE from a source column to dependent columns on joined-table rows. When False, it is assumed that the database does not enforce referential integrity and will not be issuing its own CASCADE operation for an update. The unit of work process will emit an UPDATE statement for the dependent columns during a primary key change. .. seealso:: :ref:`passive_updates` - description of a similar feature as used with :func:`_orm.relationship` :paramref:`.mapper.passive_deletes` - supporting ON DELETE CASCADE for joined-table inheritance mappers :param polymorphic_load: Specifies "polymorphic loading" behavior for a subclass in an inheritance hierarchy (joined and single table inheritance only). Valid values are: * "'inline'" - specifies this class should be part of the "with_polymorphic" mappers, e.g. its columns will be included in a SELECT query against the base. * "'selectin'" - specifies that when instances of this class are loaded, an additional SELECT will be emitted to retrieve the columns specific to this subclass. The SELECT uses IN to fetch multiple subclasses at once. .. versionadded:: 1.2 .. seealso:: :ref:`with_polymorphic_mapper_config` :ref:`polymorphic_selectin` :param polymorphic_on: Specifies the column, attribute, or SQL expression used to determine the target class for an incoming row, when inheriting classes are present. May be specified as a string attribute name, or as a SQL expression such as a :class:`_schema.Column` or in a Declarative mapping a :func:`_orm.mapped_column` object. It is typically expected that the SQL expression corresponds to a column in the base-most mapped :class:`.Table`:: class Employee(Base): __tablename__ = "employee" id: Mapped[int] = mapped_column(primary_key=True) discriminator: Mapped[str] = mapped_column(String(50)) __mapper_args__ = { "polymorphic_on": discriminator, "polymorphic_identity": "employee", } It may also be specified as a SQL expression, as in this example where we use the :func:`.case` construct to provide a conditional approach:: class Employee(Base): __tablename__ = "employee" id: Mapped[int] = mapped_column(primary_key=True) discriminator: Mapped[str] = mapped_column(String(50)) __mapper_args__ = { "polymorphic_on": case( (discriminator == "EN", "engineer"), (discriminator == "MA", "manager"), else_="employee", ), "polymorphic_identity": "employee", } It may also refer to any attribute using its string name, which is of particular use when using annotated column configurations:: class Employee(Base): __tablename__ = "employee" id: Mapped[int] = mapped_column(primary_key=True) discriminator: Mapped[str] __mapper_args__ = { "polymorphic_on": "discriminator", "polymorphic_identity": "employee", } When setting ``polymorphic_on`` to reference an attribute or expression that's not present in the locally mapped :class:`_schema.Table`, yet the value of the discriminator should be persisted to the database, the value of the discriminator is not automatically set on new instances; this must be handled by the user, either through manual means or via event listeners. A typical approach to establishing such a listener looks like:: from sqlalchemy import event from sqlalchemy.orm import object_mapper @event.listens_for(Employee, "init", propagate=True) def set_identity(instance, *arg, **kw): mapper = object_mapper(instance) instance.discriminator = mapper.polymorphic_identity Where above, we assign the value of ``polymorphic_identity`` for the mapped class to the ``discriminator`` attribute, thus persisting the value to the ``discriminator`` column in the database. .. warning:: Currently, **only one discriminator column may be set**, typically on the base-most class in the hierarchy. "Cascading" polymorphic columns are not yet supported. .. seealso:: :ref:`inheritance_toplevel` :param polymorphic_identity: Specifies the value which identifies this particular class as returned by the column expression referred to by the :paramref:`_orm.Mapper.polymorphic_on` setting. As rows are received, the value corresponding to the :paramref:`_orm.Mapper.polymorphic_on` column expression is compared to this value, indicating which subclass should be used for the newly reconstructed object. .. seealso:: :ref:`inheritance_toplevel` :param properties: A dictionary mapping the string names of object attributes to :class:`.MapperProperty` instances, which define the persistence behavior of that attribute. Note that :class:`_schema.Column` objects present in the mapped :class:`_schema.Table` are automatically placed into ``ColumnProperty`` instances upon mapping, unless overridden. When using Declarative, this argument is passed automatically, based on all those :class:`.MapperProperty` instances declared in the declared class body. .. seealso:: :ref:`orm_mapping_properties` - in the :ref:`orm_mapping_classes_toplevel` :param primary_key: A list of :class:`_schema.Column` objects, or alternatively string names of attribute names which refer to :class:`_schema.Column`, which define the primary key to be used against this mapper's selectable unit. This is normally simply the primary key of the ``local_table``, but can be overridden here. .. versionchanged:: 2.0.2 :paramref:`_orm.Mapper.primary_key` arguments may be indicated as string attribute names as well. .. seealso:: :ref:`mapper_primary_key` - background and example use :param version_id_col: A :class:`_schema.Column` that will be used to keep a running version id of rows in the table. This is used to detect concurrent updates or the presence of stale data in a flush. The methodology is to detect if an UPDATE statement does not match the last known version id, a :class:`~sqlalchemy.orm.exc.StaleDataError` exception is thrown. By default, the column must be of :class:`.Integer` type, unless ``version_id_generator`` specifies an alternative version generator. .. seealso:: :ref:`mapper_version_counter` - discussion of version counting and rationale. :param version_id_generator: Define how new version ids should be generated. Defaults to ``None``, which indicates that a simple integer counting scheme be employed. To provide a custom versioning scheme, provide a callable function of the form:: def generate_version(version): return next_version Alternatively, server-side versioning functions such as triggers, or programmatic versioning schemes outside of the version id generator may be used, by specifying the value ``False``. Please see :ref:`server_side_version_counter` for a discussion of important points when using this option. .. seealso:: :ref:`custom_version_counter` :ref:`server_side_version_counter` :param with_polymorphic: A tuple in the form ``(, )`` indicating the default style of "polymorphic" loading, that is, which tables are queried at once. is any single or list of mappers and/or classes indicating the inherited classes that should be loaded at once. The special value ``'*'`` may be used to indicate all descending classes should be loaded immediately. The second tuple argument indicates a selectable that will be used to query for multiple classes. The :paramref:`_orm.Mapper.polymorphic_load` parameter may be preferable over the use of :paramref:`_orm.Mapper.with_polymorphic` in modern mappings to indicate a per-subclass technique of indicating polymorphic loading styles. .. seealso:: :ref:`with_polymorphic_mapper_config` rz.NrargnameFc|xsddzS)Nrrrk)xs rmz!Mapper.__init__..s16Q,rlTr|)disable_inspectionrMapper[zM(None)] has None for a primary table argument and does not specify 'inherits'rrO constructed)Kr!assert_arg_typetyperz __module____name__ _sort_keyto_list_primary_key_argumentryr isinstancer+version_id_proprr9expectr<ColumnArgumentOrKeyRolerrsingler$rStrictFromClauseRoler|sa_exc ArgumentError OnClauseRolerinherit_foreign_keysdict_init_properties_delete_orphansbatcheager_defaults column_prefixrpolymorphic_abstract_dependency_processors EMPTY_DICT validatorspassive_updatespassive_deleteslegacy_is_orphan_clause_adapter_requires_row_aliasing_inherits_equated_pairs_memoized_values_compiled_cache_size_reconstructorrconfirm_deleted_rows_set_with_polymorphicpolymorphic_loadrpolymorphic_mapto_setinclude_propertiesexclude_propertiesrir rv_events_new_mapper_instance_configure_inheritance _configure_class_instrumentation_configure_properties_configure_polymorphic_setter_configure_pksrK_flag_new_mapper_log_expire_memoizationsafter_mapper_constructed)selfrzr|r r}ryrrrrrrr_polymorphic_maprrrrrrrrrrrrrrrrs rm__init__zMapper.__init__sr**64B KK " " KK   &*\\+%>"&, nn 5#1D "&D "-   11",    5 ((-D % ! )(>D %(Z 0B! ,*)   --(   %9!&(#//.. 0#&+#'+$ "$8!"!2 ==(-D %(.>D+"&"6"6"8A!00<<@F9A--5 ''5=5L5L $ 9 94;K;K6D2N ==;;GGG.1hh 88((../D+ ++d&?&?@C3;3N3N//88144D0 +/*:*:'((0'+{{$11 11@@LII&!!MM55DDEFH H '+{{$'+}}'D'D$""*&*mm&B&B#,0MM,N,N) ,,8''t}}/K/KK ++77 44@@ $(==#@#@D ,,DJ MM - - 4 4T :#}}88D #'==#@#@D  --E1E1E   $}}88D ((4,,0D0DDII !55 001J1JK  55 CG$$T%>%>?$$**6$$0 <%>?#';;D  " " *&&K  +_ &88'#'==#<#<#HH#H#'#3#3#??#?"(";";%)MM$=$=$I$I$($4$4$@$@!"# $'!'" &??'#'==#<#<#HH#H#'#3#3#??#?"("B"B%)MM$=$=$I$I$($4$4$@$@ !" #$' ''s&9[_2-A5]""_28A5_--_2c|dk(rd|_nqt|ttfr:t|dtttfrt d||_n+|df|_n!|t jd|d|_|jrV|jdG|jdtjtj|jddf|_|jr|jyy) Nrd)rdNrzTuple[ Union[ Literal["*"], Sequence[Union["Mapper[Any]", Type[Any]]], ], Optional["FromClause"], ]z&Invalid setting for with_polymorphic: rT allow_select)rrtupleliststrr rrr9rr<rrr)rrs rmrzMapper._set_with_polymorphicms s "$/D ! (5$- 8*1-UD/AB(,% )%*:4(@%  )&&89I8LM %)D !  T%:%:1%=%I%%a(  ..))!,!%%D ! ??  % % ' rlc |j}|j|j|fy|jddk7rQt|jdtsJ|j|jd|fz|jdfyy)Nrrdr)rzrrrr)rrsubcls rmr z%Mapper._add_with_polymorphic_subclasss   (  & &x 0  " "1 % ,d33A6> >>  & &&&q)UH4d6K6KA6NO -rlcL|jsJ|jrJt|tsJ||_|jjj |j|jj|_|j D]}|jd|_|jj|_ |jD]}|jj|_ |jjj||jj|_|jj|_|j j#D]=\}}||j vs|j%||ddr+|j'||d?y)zSet the given :class:`_orm.Mapper` as the 'inherits' for this :class:`_orm.Mapper`, assuming this :class:`_orm.Mapper` is concrete and does not already have an inherits.NTFlocalcolumn)rrrrurupdaterrrrself_and_descendantsrrr rrritems_should_exclude_adapt_inherited_property)rrmpkeyprops rm_set_concrete_basezMapper._set_concrete_basesc }}}==  &&)))  %%,,T-A-AB#}}<<**, 5F$$004- 5]](( ++ 7B!]]66BN 7 ))006#}}<<==44,,. AIC$++%d.B.BSd/C/..sD%@  Arlc4||_|jdy)NT)rr)rrs rm_set_polymorphic_onzMapper._set_polymorphic_ons, **40rlc Rtj|j}|jr|r |js"t j d|jz||_|jJ|j|_|jj|_ |jj|y| |jst j d|jj||jtj|j|t!j"t$j&|d}||_|jJ|j|_|jyt)j*|dt,dt!j.|jD]\}}|dk(r0t1|d r$|j2}t1|d r |j4}t7|sGt1|d r%||_t)j*|d t:dxt1|d s|j<}|j>D]P}||j@vrt j d|d|d|j@jC|||fi|_ Ry)aIf this mapper is to be a primary mapper (i.e. the non_primary flag is not set), associate this Mapper with the given class and entity name. Subsequent calls to ``class_mapper()`` for the ``class_`` / ``entity`` name combination will return this mapper. Also decorate the `__init__` method on the mapped class to include optional auto-session attachment logic. ztClass %s has no primary mapper configured. Configure a primary mapper first before setting up a non primary Mapper.NzThe _mapper() function and Mapper() constructor may not be invoked directly outside of a declarative registry. Please use the sqlalchemy.orm.registry.map_imperatively() function for a classical mapping.T)rexpired_attribute_loaderfinalizeinit)rawr_sa_original_init__func____sa_reconstructor__load__sa_validators__z+A validation function for mapped attribute z on mapper z already exists.)"ropt_manager_of_classrzry is_mappedrInvalidRequestErrorrrKrr_add_non_primary_mapperrvinstrument_classrregister_classr!partialrload_scalar_attributesr1listen_event_on_inititerate_attributeshasattrr.r/callabler_event_on_load__sa_validation_opts__r2runion)rmanagerr$methodvalidation_optsnames rmrz'Mapper._configure_class_instrumentations]11$++>   '"3"300 $ , ")D ##/ //#,,DM#*>>#A#AD    4 4T :  ?'"2"2,,4  &&tT[[9"00 KK%)\\..&   %+++((  >> !  Wfn$?224;;? KCj WV5H%I116:.#__F6#9:*0D'LL&.dKV%89&,&C&CO & 8 8 4??2"("<"<$(!/# +///*?*?!FO#<=+  rlcfd|_d|_d|_|jj ddy)NTrw)r_ready_for_configure_dispose_called__dict__poprs rm_set_dispose_flagszMapper._set_dispose_flagss.$(!# -t4rlcP |j|} |j}t |tstjd|d|d|S#t$r"}tjd|d|d|d}~wwxYw#t $r"}tjd|d|d|d}~wwxYw)NzCan't determine z column 'z(' - no attribute is mapped to this name.z4'; property does not refer to a single mapped Column)rKeyErrorrrr:AttributeErrorrrA)rrr$r%errexpraes rm_str_arg_to_mapped_colzMapper._str_arg_to_mapped_col!s ;;s#D  ??D $'&&"7)9SE:     % &&"7)9SE:77   &&"7)9SE:DD  s.A A: A7A22A7: B%B  B%c0 tjj_jj djDi_i_tjtjDcgc]}|jc}}tjd|D}tjjjgD]}|jrV|j!|jr;tj"|jj%|j |<tj"|j&j%|j|<j(rCdj(DDcgc]&}t+|t,rj/d|n|(}}nd}|rs|D]m}|j0j vr+tj2j |j0<j |j0j5|onՉjj vs%t7j jdk(r0t9j:ddjj<dj>j vrPt+j>t@jBr,tjDd j>j<zjFr4jHs(j(sjFj_n|r"fd |DDcgc] \}}||n| } }}n.tjJj jd } t7| dk(r0t9j:ddjj<dtM| _jOd | jDchc]P}j|jPvr3tS|dr|j0jvrj|Rc}_*ycc}wcc}wcc}}wcc}w)Nc3 K|]}|ywrhrk).0ts rm z(Mapper._configure_pks..;s7a7s c3:K|]}|js|ywrh)r})rVrs rmrXz(Mapper._configure_pks..Ds!G!!Gsc3hK|]*}tjtj|d,yw)r}rN)r9rr<DDLConstraintColumnRole)rV coerce_pks rmrXz(Mapper._configure_pks..[s9 " $$55! -s02r}rzMapper z> could not assemble any primary key columns for mapped table 'rzlCould not assemble any primary keys for locally mapped table '%s' - no rows will be persisted in this Table.c3XK|]!}jj||f#ywrh)rcorresponding_column)rVrrs rmrXz(Mapper._configure_pks..s/"00EEaH!L"s'*T)ignore_nonexistent_tablesz"Identified primary key columns: %sr)+r find_tablesrrrrrrr! column_setrr proxy_setrjrBr} issupersetordered_column_set intersectionrrrrrSrr^addlenrrrr|r4rBr rrreduce_columnsrr_identity_key_propsr>_readonly_props) rcolall_colspk_colsfcrcoerced_pk_argkccr}s ` rmrzMapper._configure_pks8s **4+B+BC  74;;77 ?? T-C-CDcCMMD E //!GX!GGdkk"(($*A*A)BC B~~'"4"4R^^"D*.)@)@NN*,""2& '+&=&=bdd&C&P&P'D   #   % % &*%?%?   "!S)// qAN "N # 377$"4"4426//2CD&&qww/""177+//2 3  # #4+=+= =4%%d&=&=>?1D&&00<<>    T%7%7 7J   fll=  II;""../  MMMM.. $}}88D  "!/"A.Ba/ '55&&t'>'>?.2 ;1$**T44@@B %[1D  II:K H -- %%c*$2J2JJC)99D$7$77  " "3 ' YE(v: sR ++R5R %ARctjx|_|_t j |_t||_i}i}|jr|jjD]\}}t|ts|j||}n|}d}t|tjrE|jD]6}|j jj#|s)d}|||<||f||<8|s|j%||d|j&r|j&j jD]\}}|j)||ddr|j+|} | r3|j-||d| } | ||<| jD] } || f|| < b||j vsq|j/||d|j0jD]} | |vr|| \}} |j%|| d$| |jvr3|j2xsd| j4z}|j)| j4||j jj#| | r|j7D]*}| |jvs|j| j4},|j%|| ddy)NTF)r,r) warn_only incoming_propr, setparent)sql_baseColumnCollectionrrr! OrderedDictrrrrr rr+_make_prop_from_columnr rRr|contains_column_configure_propertyrr!get%_reconcile_prop_with_incoming_columnsr"rrr$r)rexplicit_col_props_by_columnexplicit_col_props_by_keyr$prop_argpossible_col_prop_map_as_property_now given_colinherited_proprtnew_propinc_colrr% column_keyrs rmrzMapper._configure_propertiess! ( 9 9 ;; tv&&( "0!5  %EG!  !%!6!6!  X!(N;(,(C(CX)%)1%(,$/1J1JK%6%>%> ++--==iH380=N5c: # 1G8C (,,)"-3 D =='+}}';';'A'A'C O#^''Sd'K 9 = =c B  #II&"'&3 J H 6>-c2#0#8#8$A4W=  +223N) O8--55 F559@ T((d(?4111,,2fjj@J## &&((88@ $ ..0 FV555!'!9!9&!A!E!EJ F  $ $ % 7 rlc* d}d |j*d}t|jtr |j|j|_|j|jvr|j|j}nt|jtrGt|jtjst j d|j}n:|jj|j}|d}d}|j}t|tjr^|j.|jd|jdj| $t j d|j"zd}t%|dd}|r,|j'||d|r._set_polymorphic_identitys  MM((==%)0 ,,AA 446u}}7K7K6LMEE /33( rlc||vr7||jvr%tjdt||fyyy)NznFlushing object %s with incompatible polymorphic identity %r; the object may not refresh and/or load correctly)"_acceptable_polymorphic_identitiesr! warn_limitedr')rrrrs rmrzLMapper._configure_polymorphic_setter.._validate_polymorphic_identitysW#u,o.!DDE%%G#5)5+AB E-rl)rrrrrNrrrr+r rRrr^r4rArr5rgetattrr!labelr$r}rrrrrr) rr,setterrPr%rk instrumentr$rrrrs @rmrz$Mapper._configure_polymorphic_setter+s)-    *F$--s3*.++d6I6I*JD'""d&<&<<--d.A.ABD//@"'')B)B!..; **--BB'';#F!&J--C!#v}}5--5003;003HHM %88?"oo."&Jc5$/++CeSA$8868;< 14 :N0OOD'#''C!00*M((d(N#',,q/D "hhO..0  ((4..&2K2KK.4.C.C+!33..v/D/DE+ **6"<<6#882#AA; :>6592; >  $ $)<)<)D,,P   0*9D & .GD *.  /*.D &-1D *]  ../151D1DE sM!! N*#N  NcN|j|j|jSyrh)rrrs rm_version_id_propzMapper._version_id_props(    *))$*=*=> >rlct}t|g}|ra|j}|j|jur6|j |j |j |j|ra|Srh)rjrpopleftrrfrextendr)r identitiesstackitems rmrz)Mapper._acceptable_polymorphic_identitiessgU tf ==?D&&$*A*AAt889 T556  rlcHt|jjSrh) frozensetrvaluesrs rm _prop_setzMapper._prop_sets++-..rlzsqlalchemy.orm.descriptor_propsctjj}|js|j ||ddy||j vrx|j j||}||us2t|tjr=|j|jur$|j ||j|dyyyy)NFrvT)r! preloadedorm_descriptor_propsrr}rr_get_class_attr_mrorrInstrumentedAttribute _parententityparentConcreteInheritedProperty)rr$r%r,descriptor_propsimplementing_attributes rmr"z Mapper._adapt_inherited_property s>>>>}}  $ $S$Ue $ L  #&*%7%7%K%KT& "&-*J,L,L+88DKKG(($>>@" )H$rl)r,rwwarn_for_existingc , tjj}|jd||jj t |ts|j||}n|}t |tjrT|jj|jd}||jr|g} |jjD]} | j j|jd}|L| D]} | jj#||jj|jd}n| j%| |[|jd}t'|drt'|dr|j(|j*vr|j,j/|ngt'|dr[|j(|j*vrC||j*|j(vr(|j*|j(j/|t'|ds0||j0uxs|jd|j0u|_t |t4j6r|x|_|_|jj/|||jD]"}|j<D]} ||j>| <$tA|d||k7rWtjBd|jDj d |j8d |d |j8d |j8d ||_|r|jG||||jHvrTtA|jH|d dr:|jH|jJ} tMjNd| d|d|d| ||jHvrt |jH||jPsxt ||jRsb|r4tjTd|jDj d |d|dd|jH|}|jVjY|dn|r|jDjZj]|dzt ||jRsdt |jHj]|d|jPs4tjTd|jDj d |d|dd||jH|<|j^s|ja||jbD]}|je||||r!|jg|ji||jjr|jm|S)Nz_configure_property(%s, %s)rrjrr_is_polymorphic_discriminatorr$zORM mapped property rz being assigned to attribute z& is already associated with attribute z+. The attribute will be de-associated from _mapped_by_synonymFz'Can't call map_column=True for synonym =z4, a ColumnProperty already exists keyed to the name z for column zUser-placed attribute z on z is replacing an existing ORM-mapped attribute. Behavior is not fully defined in this case. This use is deprecated and will raise an error in a future releasez2.0z is replacing an existing class-bound attribute of the same name. Behavior is not fully defined in this case. This use is deprecated and will raise an error in a future release)7r!rrr __class__rrr+_property_from_columnr rRrr^rrrr|_refresh_for_new_columnr r>rrrjrfrrr:Labelr$ _tq_key_labelrbrrr rz set_parentrrrrrrNwarn_deprecatedrrKrJr~ryr7rr"r,post_instrument_classrr)rr$rr,rwrrr%rkpathmm2 proxy_colsynoldproprs rmr}zMapper._configure_property(s >>>> )30B0B0K0K (N3(,(B(BX)DD dJ55 6))>>t||AOC {t}}v668 #A--<||A$*=*==2 #z//0/21#+ LL  S# &|| =!$=I8auD&    C  ! !$ '.. >F  , ,S$ = >  IIK  & &t , ??  % % ' rlc tj|}g}|D]}|jj|}|t|jj|}||jj ||jj|}|t jd|d|d|d|j|tj|S)NzWhen configuring property '' on , column 'z' is not represented in the mapper's table. Use the `column_property()` function to force this column to be mapped as a read-only attribute.) r!rrr^r|rrrr r rR)rr$rr mapped_columnrmcs rmr{zMapper._make_prop_from_columns,,v&  %A((==a@Bz%%::1=> ++CCBG,,AA!D: .. ),T1 6   $' %(((-88rlc|r(|jst|tjs|S|jd}|r||jvr|S||J|}|jd|f}n$|J|jd}||jdf}|j r||j vrs|j |sb||jurT||jurFd|jdd|d|d} |rtj| ntj| |j} | jjd||jd|| S)NrzImplicitly combining column z with column z under attribute 'zT'. Please configure one or more attributes for these same-named columns explicitly.zAinserting column to existing list in properties.ColumnProperty %s)rrr rRrrshares_lineagerr!r rr5copyinsertr) rr$ existing_proprsrt single_columnexisting_columnincoming_columnequated_pair_keymsgrs rmrz,Mapper._reconcile_prop_with_incoming_columnssn  MMmZ-F-FG '//2 _ 0E0EE   , ,,+O - 5 5a 8/J  ( ((+33A6O /1F1Fq1IJ 00$D,H,HH#22?Ct':'::t':'::"))"-#  #0055 !%%'?3  .  rlc tjj}|jj |}t |t jr!|j||||j|uS|t ||jr|j||Stjd|d|d|jd|d )zrgenerate/update a :class:`.ColumnProperty` given a :class:`_schema.Column` or other SQL expression object.)rrsz$WARNING: when configuring property 'rrz' conflicts with property 'aG'. To resolve this, map the column to the class under a different name in the 'properties' dictionary. Or, to remove all awareness of the column entirely (including its availability as a foreign key), use the 'include_properties' or 'exclude_properties' mapper arguments to control specifically which table columns get mapped.)r!rrrr~rr rRrrrr{rrr$)rr$rrr%s rmrzMapper._property_from_column4 s >>>>{{s# dJ55 6==$++T1 >  \Z "<< ..sF; ;&&*-dFJJF  rlzThis warning originated from the `configure_mappers()` process, which was invoked automatically in response to a user-initiated operation.cb|jjrt|jhdyy)NTcascade)rK _new_mappers_configure_registriesrs rm_check_configurezMapper._check_configureY s& == % % !4==/4 @ &rlc|jd|jjDcgc] \}}||f }}}|D]_\}}|jd||j|ur|js|j |j sO|j|a|jdd|_ycc}}w)zCall the ``init()`` method on all ``MapperProperties`` attached to this mapper. This is a deferred configuration step which is intended to execute once all mappers have been constructed. z$_post_configure_properties() startedzinitialize prop %sz%_post_configure_properties() completeTN) rrr r_configure_startedr,_configure_finishedrr)rr$r%ls rm_post_configure_propertiesz!Mapper._post_configure_propertiesc s 89*.++*;*;*= >YS$c4[ > > 1IC II*C 0{{d"4+B+B ''**40 1 9: ?sB=cX|jD]\}}|j||y)z^Add the given dictionary of properties to this mapper, using `add_property`. N)r  add_property)rdict_of_propertiesr$values rmadd_propertieszMapper.add_propertiesz s0 -224 *JC   c5 ) *rlc|j|||jd}t|tsJ||j|<y)aAAdd an individual MapperProperty to this mapper. If the mapper has not been configured yet, just adds the property to the initial properties dictionary sent to the constructor. If this Mapper has already been configured, then the given MapperProperty is configured immediately. T)r,rN)r}rrr+r)rr$r%s rmrzMapper.add_property sH'' DOOt( $///%)c"rlcN|jD]}|jyrh)r_reset_memoizationsrrs rmrzMapper._expire_memoizations s&**, )F  & & ( )rlcd|jjzdz|jduxr|jjxst |jz|j xrdxsdzdzS)N(|z |non-primaryru))rzrr|rrryrs rm _log_desczMapper._log_desc s kk"" #   ,1$$00)t''(  2N8b :  rlc`|jjd|zg|jf|zyNz%s )loggerinforrrargss rmrz Mapper._log s+ B(9D(@Brlc`|jjd|zg|jf|zyr)rdebugrrs rm _log_debugzMapper._log_debug s+ %#+C$..):T)ACrlcJdt||jjfzS)Nz)idrzrrs rm__repr__zMapper.__repr__ s %D4;;3G3G(HHHrlcd|jj|jxrdxsdd|j|jjdS|j jdS)Nrz (non-primary)rurz)])rzrryr|rrrs rm__str__zMapper.__str__ st KK    1!1 7R 7##/  ,,9   ,,889   rlc"d}|jD]l}|jD][\}}d}tj|j |||j }|j r|ry|j rW|rZyn|j r|Sy)NFT) optimistic)rrrmanager_of_class has_parent has_identityr)rrorphan_possiblerr$clsrs rm _is_orphanzMapper._is_orphan s**, F"22 S"&'88=HH35+=+=I ((Z ..z    " "rlc||jvSrh)r)rr$s rm has_propertyzMapper.has_property sdkk!!rlc|r|j |j|S#t$r"}tjd|d|d|d}~wwxYw)z6return a MapperProperty associated with the given key.zMapper 'z' has no property 'zw'. If this property was indicated from other mappers or configure events, ensure registry.configure() has been called.N)rrrNrr5)rr$_configure_mappersrPs rm get_propertyzMapper.get_property sg   ! ! # ;;s# # ,,4& 3C5988   s# AA  Ac |j|S)zkGiven a :class:`_schema.Column` object, return the :class:`.MapperProperty` which maps this column.)r)rrs rmget_property_by_columnzMapper.get_property_by_column s %%f--rlcHt|jjS)z1return an iterator of all MapperProperty objects.)iterrrrs rmiterate_propertieszMapper.iterate_properties sDKK&&())rlc0|dk(rt|j}n|rt}tj|D]k}t |}|j |stj|d|| |j|j[|j|m|jDcgc] }||vs| }}ng}|>ttj|d}|Dcgc]}|j|vs|}}|Scc}wcc}w)zgiven a with_polymorphic() argument, return the set of mappers it represents. Trims the list of mappers to just those represented within the given selectable, if present. This helps some more legacy-ish mappings. rdz does not inherit from T)include_aliases)rrrjr!rr#isarr5rrrfrr`r|)rspec selectablemappers mapper_setrrs rm_mappers_from_speczMapper._mappers_from_spec s 3;4445G +.5J\\$' &$Q'uuT{ 449:DA%%%a&7&7&9:NN1% &#'";";OQqJqOGOG  !$$ZFF#*EQQ]]f-DqEGEPFs9 DD2DDc0|j}|D]}||ur|jrtjd|jr6|r'|j |j |j}_|j|j |j}|S)zgiven a list of mappers (assumed to be within this mapper's inheritance hierarchy), construct an outerjoin amongst those mapper's mapped tables. z^'with_polymorphic()' requires 'selectable' argument when concrete-inheriting mappers are used.) rrrr5rrr|r outerjoin)rr innerjoinfrom_objrs rm_selectable_from_mapperszMapper._selectable_from_mappers s** ADyzz00AXX'}} q':': H (11 q':': H $rlc|j}|yt|tsy|jduxs@|jduxr0|jj xr|jj SNFT)rrrAserver_defaultdefault is_scalar is_callable)rvid_cols rm!_version_id_has_server_side_valuez(Mapper._version_id_has_server_side_value1 sp%% ?GV,))5t+1118#OO777  rlc |jrs|jrg|j[|jj||dj |j Dcgc]}|j s |jc}Sycc}w)N) parententity parentmapper)rrr _annotatein_rrrrrs rm_single_table_criterionzMapper._single_table_criterionC s| ;;4==T-@-@-L&&00!%t<c"6611** sBcl|jxr't|jdtjS)zreturn True if with_polymorphic[1] is an aliased fromclause, like a subquery. As of #8168, polymorphic adaption with ORMAdapter is used only if this is present. r)rrr:AliasedReturnsRowsrs rm#_has_aliased_polymorphic_fromclausez*Mapper._has_aliased_polymorphic_fromclauseR s5$$   ! !! $  ) )*  rlc|jxs<|jxs.|jjxs|jjS)a;determine if _MapperEntity or _ORMColumnEntity will need to use polymorphic adaption when setting up a SELECT as well as fetching rows for mapped classes and subclasses against this Mapper. moved here from context.py for #8456 to generalize the ruleset for this condition. )r*rrrs rm _should_select_with_poly_adapterz'Mapper._should_select_with_poly_adapter` sKV  4 4 7** 7  DD 766  rlcp|j|jsgS|j|jSrh)rrrrs rm_with_polymorphic_mappersz Mapper._with_polymorphic_mappers s5 $$I&t&&(=(=>>rlc$|jy)zThis hook is invoked by attribute inspection. E.g. when Query calls: coercions.expect(roles.ColumnsClauseRole, ent, keep_inspect=True) This allows the inspection process run a configure mappers hook. N)rrs rm _post_inspectzMapper._post_inspect s rlc|js |jS|j\}}||S|j|j||dSNF)rrrr)rrrs rm_with_polymorphic_selectablez#Mapper._with_polymorphic_selectable sX$$** *00j  ! 00''j95 rlc |jjDcic]\}}|td|Dc}}Scc}}w)Nc3NK|]}|jjs|ywrh)rshould_evaluate_nonerVrks rmrXz6Mapper._insert_cols_evaluating_none.. s!#((*G*Gs%%rr rrrrs rm_insert_cols_evaluating_nonez#Mapper._insert_cols_evaluating_none sR #'"5"5";";"=  w 9&    ?c |jjDcic]\}}|td|Dc}}Scc}}w)Nc3K|]J}|js<|js0|js$|jjs|j Lywrh)r}rrrr6r$r7s rmrXz.Mapper._insert_cols_as_none.. s@** 55 sAAr8r9s rm_insert_cols_as_nonezMapper._insert_cols_as_none sR#'"5"5";";"=  w 9"    r;c |jjDcic].\}}||Dcic]}|j|j|c}0c}}}Scc}wcc}}}wrh)rr rr$rrrrks rm_propkey_to_colzMapper._propkey_to_col se#'"5"5";";"=  w GLSD**3/33S8L L  L s A!A AAc |jjDcic])\}}|t|Dcgc]}|jc}+c}}}Scc}wcc}}}wrh)rr rr$rrpksrks rm_pk_keys_by_tablezMapper._pk_keys_by_table sX#00668  s 95#cgg56 6  5 sAA AAc |jjDcic]6\}}|t|Dcgc]}|j|jc}8c}}}Scc}wcc}}}wrh)rr rrr$rCs rm_pk_attr_keys_by_tablezMapper._pk_attr_keys_by_table se#00668  s 9M#d44S9==MN N  M sA$ A A$A$c |jjDcic]W\}}|ttd|Dcgc]2}|j"|j |j j r|4c}Yc}}}Scc}wcc}}}wNzIterable[Column[Any]])rr rr rris_clause_elementr@s rm_server_default_colszMapper._server_default_cols s #'"5"5";";"=   w 9 $$;WE))5 /KK99       B7B2 BBc |jjDcic]W\}}|ttd|Dcgc]2}|j"|j |j j r|4c}Yc}}}Scc}wcc}}}wrI)rr rr server_onupdateonupdaterJr@s rm_server_onupdate_default_colsz$Mapper._server_onupdate_default_cols s #'"5"5";";"=   w 9 $$;WE**6 0LL::       rLc |jjDcic]\}}|td|Dc}}Scc}}w)Nc3NK|]}|j|jywrhr$r7s rmrXz2Mapper._server_default_col_keys.. L8KSWWL%%)rKr rrrcolss rmrzMapper._server_default_col_keys sG $88>>@ t 9LLL L   r;c |jjDcic]\}}|td|Dc}}Scc}}w)Nc3NK|]}|j|jywrhrSr7s rmrXz;Mapper._server_onupdate_default_col_keys.. rTrU)rPr rrVs rm!_server_onupdate_default_col_keysz(Mapper._server_onupdate_default_col_keys sG $AAGGI t 9LLL L   r;c`t}|j|jjD].\}}|j fd|j D0|j jD].\}}|j fd|j D0|S)Nc3<K|]}|jywrhrSrVrkcol_to_propertys rmrXz@Mapper._server_default_plus_onupdate_propkeys..! $ $((c3<K|]}|jywrhrSr]s rmrXz@Mapper._server_default_plus_onupdate_propkeys..& r_r`)rjrrKr rrerP)rresultrrr^s @rm&_server_default_plus_onupdate_propkeysz-Mapper._server_default_plus_onupdate_propkeys s500"77==? NE7 MM"//@   #@@FFH NE7 MM"//@    rlc|||d}|j|jur4|jj|||djd|d|d<|jj|jd|dS)N)entity_namespacer"r#ormcompile_state_pluginplugin_subject dml_table)rr|r$_set_propagate_attrsr)rrs rm__clause_element__zMapper.__clause_element__, s!%  '  " "$*:*: :(,'7'7'A'A(,$($(( #").$G  $((5JJ%*d C  rlcvtjj|||ddjd|dS)NT)rer"r#identity_tokenrfrg)r:nullr$rkrs rmselect_identity_tokenzMapper.select_identity_tokenD sC OO  Y(,$($(&* " !).$G rlc|jS)a4The :class:`_schema.FromClause` construct this :class:`_orm.Mapper` selects from by default. Normally, this is equivalent to :attr:`.persist_selectable`, unless the ``with_polymorphic`` feature is in use, in which case the full "polymorphic" selectable is returned. )r3rs rmrzMapper.selectableU s000rlc|dvr&tjtj|d}|jr%|s|jd}|dur|jd}n|durd}|j ||}|||fS||j ||fS)Nr2TrrFr)r9rr<rrrr)rrrrrs rm_with_polymorphic_argszMapper._with_polymorphic_argsa s ] *"))**JTJ  ,,Q/U"!2215 5 J))$ ;  !J& &D99'9MM MrlcJt|j|jSrh)r_iterate_polymorphic_propertiesr.rs rm_polymorphic_propertieszMapper._polymorphic_propertiesy s&  0 0..   rlc|j}|j}|Dcgc]L}t|tjr0|j r$|j D]}|r|j |n|Nc}}Scc}}wrh)rv_polymorphic_adapterrr rR_renders_in_subqueriesr)rpoly_propertiesadapterr%rs rm_all_column_expressionszMapper._all_column_expressions s|66++( $ 9 9:++\\   #*GOOA q 0 0   sAA3c|r|j|}n |j}|Dcgc]7}t|tjr|j |j df9c}Scc}w)Nr)rurvrr rRr$r)rpolymorphic_mappersrzr%s rm_columns_plus_keyszMapper._columns_plus_keys sh "BB#O#::O( $ 9 9:XXt||A '   s+>> sAB-B( !A B-c`|jtj|jS)aiA namespace of all :class:`.MapperProperty` objects associated this mapper. This is an object that provides each property based on its key name. For instance, the mapper for a ``User`` class which has ``User.name`` attribute would provide ``mapper.attrs.name``, which would be the :class:`.ColumnProperty` representing the ``name`` column. The namespace object can also be iterated, which would yield each :class:`.MapperProperty`. :class:`_orm.Mapper` has several pre-filtered views of this attribute which limit the types of properties returned, including :attr:`.synonyms`, :attr:`.column_attrs`, :attr:`.relationships`, and :attr:`.composites`. .. warning:: The :attr:`_orm.Mapper.attrs` accessor namespace is an instance of :class:`.OrderedProperties`. This is a dictionary-like object which includes a small number of named methods such as :meth:`.OrderedProperties.items` and :meth:`.OrderedProperties.values`. When accessing attributes dynamically, favor using the dict-access scheme, e.g. ``mapper.attrs[somename]`` over ``getattr(mapper.attrs, somename)`` to avoid name collisions. .. seealso:: :attr:`_orm.Mapper.all_orm_descriptors` )rr!ReadOnlyPropertiesrrs rmattrsz Mapper.attrs s&F &&t{{33rlcntjt|jj S)ay A namespace of all :class:`.InspectionAttr` attributes associated with the mapped class. These attributes are in all cases Python :term:`descriptors` associated with the mapped class or its superclasses. This namespace includes attributes that are mapped to the class as well as attributes declared by extension modules. It includes any Python descriptor type that inherits from :class:`.InspectionAttr`. This includes :class:`.QueryableAttribute`, as well as extension types such as :class:`.hybrid_property`, :class:`.hybrid_method` and :class:`.AssociationProxy`. To distinguish between mapped attributes and extension attributes, the attribute :attr:`.InspectionAttr.extension_type` will refer to a constant that distinguishes between different extension types. The sorting of the attributes is based on the following rules: 1. Iterate through the class and its superclasses in order from subclass to superclass (i.e. iterate through ``cls.__mro__``) 2. For each class, yield the attributes in the order in which they appear in ``__dict__``, with the exception of those in step 3 below. In Python 3.6 and above this ordering will be the same as that of the class' construction, with the exception of attributes that were added after the fact by the application or the mapper. 3. If a certain attribute key is also in the superclass ``__dict__``, then it's included in the iteration for that class, and not the class in which it first appeared. The above process produces an ordering that is deterministic in terms of the order in which attributes were assigned to the class. .. versionchanged:: 1.3.19 ensured deterministic ordering for :meth:`_orm.Mapper.all_orm_descriptors`. When dealing with a :class:`.QueryableAttribute`, the :attr:`.QueryableAttribute.property` attribute refers to the :class:`.MapperProperty` property, which is what you get when referring to the collection of mapped properties via :attr:`_orm.Mapper.attrs`. .. warning:: The :attr:`_orm.Mapper.all_orm_descriptors` accessor namespace is an instance of :class:`.OrderedProperties`. This is a dictionary-like object which includes a small number of named methods such as :meth:`.OrderedProperties.items` and :meth:`.OrderedProperties.values`. When accessing attributes dynamically, favor using the dict-access scheme, e.g. ``mapper.all_orm_descriptors[somename]`` over ``getattr(mapper.all_orm_descriptors, somename)`` to avoid name collisions. .. seealso:: :attr:`_orm.Mapper.attrs` )r!rrr_all_sqla_attributesrs rmall_orm_descriptorszMapper.all_orm_descriptors s/D&& ##88: ;  rlc^tjj}|jDchc]}|j}}|j j Dcic]@\}}t||jr%|j|vr|j|jBc}}Scc}wcc}}w)z~return a dictionary of {syn_attribute_name: pk_attr_name} for all synonyms that refer to primary key columns ) r!rrrir$rr rrNrF)rrr%pk_keysrprs rm _pk_synonymszMapper._pk_synonyms1 s >>>>(,(@(@A488AA++++- 3#/??@G# GGSXX   B s B$AB)cltjj}|j|jS)zReturn a namespace of all :class:`.Synonym` properties maintained by this :class:`_orm.Mapper`. .. seealso:: :attr:`_orm.Mapper.attrs` - namespace of all :class:`.MapperProperty` objects. )r!rr_filter_propertiesrN)rrs rmsynonymszMapper.synonymsC s, >>>>&&'7'G'GHHrlc|jSrhrrs rmrezMapper.entity_namespaceT s {{rlc@|jtjS)aReturn a namespace of all :class:`.ColumnProperty` properties maintained by this :class:`_orm.Mapper`. .. seealso:: :attr:`_orm.Mapper.attrs` - namespace of all :class:`.MapperProperty` objects. )rr rRrs rm column_attrszMapper.column_attrsX s&&z'@'@AArlzsqlalchemy.orm.relationshipsch|jtjjjS)aDA namespace of all :class:`.Relationship` properties maintained by this :class:`_orm.Mapper`. .. warning:: the :attr:`_orm.Mapper.relationships` accessor namespace is an instance of :class:`.OrderedProperties`. This is a dictionary-like object which includes a small number of named methods such as :meth:`.OrderedProperties.items` and :meth:`.OrderedProperties.values`. When accessing attributes dynamically, favor using the dict-access scheme, e.g. ``mapper.relationships[somename]`` over ``getattr(mapper.relationships, somename)`` to avoid name collisions. .. seealso:: :attr:`_orm.Mapper.attrs` - namespace of all :class:`.MapperProperty` objects. )rr!rorm_relationshipsrSrs rm relationshipszMapper.relationshipsf s*6&& NN , , A A  rlch|jtjjjS)zReturn a namespace of all :class:`.Composite` properties maintained by this :class:`_orm.Mapper`. .. seealso:: :attr:`_orm.Mapper.attrs` - namespace of all :class:`.MapperProperty` objects. )rr!rrrMrs rm compositeszMapper.composites s*&& NN / / A A  rlc|jtjtjfd|jj DS)Nc3FK|]\}}t|s||fywrh)r)rVrpvtype_s rmrXz,Mapper._filter_properties.. s'1a*Q:NAs! !)rr!rrzrr )rrs `rmrzMapper._filter_properties sL &&   #';;#4#4#6   rlc ,t|jdDcgc]+\}}|tjd|z|jf-}}}tj |Dcgc] \}}||k( c}}t j|fScc}}wcc}}w)zcreate a "get clause" based on the primary key. this is used by query.get() and many-to-one lazyloads to load this item by primary key. rzpk_%dr) enumerater}r5 bindparamrand_r! column_dict)ridxr}paramsrprs rm _get_clausezMapper._get_clause s%.d.>.>$B  ![ gm;3C3CD    HHF3&1aqAv3 4   V $   4s 0B !B cifd}|jjD]2}|jtj|jid|i4S)aSCreate a map of all equivalent columns, based on the determination of column pairs that are equated to one another based on inherit condition. This is designed to work with the queries that util.polymorphic_union comes up with, which often don't include the columns from the base table directly (including the subclass table columns only). The resulting structure is a dictionary of columns mapped to lists of equivalent columns, e.g.:: {tablea.col1: {tableb.col1, tablec.col1}, tablea.col2: {tabled.col2}} c|jtjk(r|jvr)|jj |j n|j h|j<|j vr)|j j |jy|jh|j <yyrh)operatorr;eqleftrfright)binaryrbs rm visit_binaryz0Mapper._equivalent_columns..visit_binary s),,.;;&(6;;'++FLL9+1<<.F6;;'<<6)6<<(,,V[[9,2KK=F6<<(/rlr)rrrr>traverse)rrrrbs @rmrzMapper._equivalent_columns s_ (* 9&&;; F''3!!,,b8\2J   rlc~t|ttjtj fry||j vSr2)rr(rrPr:r\_dataclass_fields)r assigned_nameobjs rm_is_userland_descriptorzMapper._is_userland_descriptor s=   ,,((   (>(>> >rlcztj|jDcgc]}|jc}Scc}wrh)r!dataclass_fieldsrzrF)rfs rmrzMapper._dataclass_fields s) $ 5 5dkk BC1CCCs8c8|tj|ry|rQ|jjj |d [|j ||jj|r2y|j j|d}||j ||ry|j3||jvr%|||jvr|jd|zy|j3||jvs|#||jvr|jd|zyy)zdetermine whether a particular property should be implicitly present on the class. This occurs when properties are propagated from an inherited class, or are applied from the columns present in the mapped table. NTznot including property %szexcluding property %sF) rx_never_select_columnrzrJr~rrrrrr)rrFrrrattrs rmr!zMapper._should_exclude s(  ("?"?"G {{##''t"::t{{33MB%%99-NDD$@$@t%  # # /D33361H1H#H II1T: ;  " " . D++ +"v1H1H'H II-6 7rlc2|j|juS)zXReturn true if the given mapper shares a common inherited parent as this mapper.)rrothers rm common_parentzMapper.common_parent s5#4#444rlc|j|juxr&|j| xr|j| S)z{return true if the other mapper is an inheriting sibling to this one. common parent but different branch )rrrs rm is_siblingzMapper.is_sibling sC    1 1 1 $HHUO# $IIdO# rlc|j}|j|rt|j|St||uSrh)primary_mapperrr%r)rrallow_subtypesss rm_canloadzMapper._canload( sF    !    *n '++A. . '1, ,rlcN|}|r||ur|j}|r||urt|S)z>Return True if the this mapper inherits from the given mapper.)rr~)rrrs rmrz Mapper.isa1 s/$(AUN AAUNAwrlc#<K|}|r||j}|ryywrh)rr&s rmrzMapper.iterate_to_root9 s!#'G Ascg}t|g}|r?|j}|j||j|j|r?t j |S)zThe collection including this mapper and all descendant mappers. This includes not just the immediately inheriting mappers but all their inheriting mappers as well. )rrr rrr!r)r descendantsrrs rmrzMapper.self_and_descendants? sZ tf ==?D   t $ LL11 2  --rlc,t|jS)aCIterate through the collection including this mapper and all descendant mappers. This includes not just the immediately inheriting mappers but all their inheriting mappers as well. To iterate through an entire hierarchy, use ``mapper.base_mapper.polymorphic_iterator()``. )r rrs rmpolymorphic_iteratorzMapper.polymorphic_iteratorO sD--..rlc.|jjS)zSReturn the primary mapper corresponding to this mapper's class key (class).)rrrs rmrzMapper.primary_mapper\ s!!(((rlcB|jjjSrh)rrrrs rmprimary_base_mapperzMapper.primary_base_mapperb s!!((444rlc|'|jDcgc]}|j|}}n |j}|j}|D]}||vsyycc}wr)r}rkeys)rrbr{rrmrkrks rm_result_has_identity_keyzMapper._result_has_identity_keyf sd  373C3CDawq)DGD&&G [[] C"} EsAc|'|jDcgc]}|j|}}n |j}t|dr |jn||jt fd|D|fScc}w)aReturn an identity-map key for use in storing/retrieving an item from the identity map. :param row: A :class:`.Row` or :class:`.RowMapping` produced from a result set that selected from the ORM mapped primary key columns. .. versionchanged:: 2.0 :class:`.Row` or :class:`.RowMapping` are accepted for the "row" argument _mappingc3(K|] }| ywrhrk)rVrmappings rmrXz/Mapper.identity_key_from_row.. s8f'&/8s)r}rr>rrr)rrowrnr{rrmrs @rmidentity_key_from_rowzMapper.identity_key_from_rows s~$  373C3CDawq)DGD&&G 3 #llGG  88 8   EsA3c2|jt||fS)zReturn an identity-map key for use in storing/retrieving an item from an identity map. :param primary_key: A list of values indicating the identifier. )rr)rr}rns rmidentity_key_from_primary_keyz$Mapper.identity_key_from_primary_key s"  +    rlcltj|}|j|tjS)aReturn the identity key for the given instance, based on its primary key attributes. If the instance's state is expired, calling this method will result in a database check to see if the object has been deleted. If the row no longer exists, :class:`~sqlalchemy.orm.exc.ObjectDeletedError` is raised. This value is typically also found on the instance state under the attribute name `key`. rinstance_state_identity_key_from_stater& PASSIVE_OFF)rinstancers rmidentity_key_from_instancez!Mapper.identity_key_from_instance s-))(3,,UK4K4KLLrlc |j}|j}|jt|jDcgc],}||j j j|||.c}|jfScc}wrh) rrCrrrir$implr~rn)rrpassiverrCr%s rmrzMapper._identity_key_from_state s}  --  !% 8 8DHH%**..ueWE     s1A; cvtj|}|j|tj}|dS)aGReturn the list of primary key values for the given instance. If the instance's state is expired, calling this method will result in a database check to see if the object has been deleted. If the row no longer exists, :class:`~sqlalchemy.orm.exc.ObjectDeletedError` is raised. rr)rrr identity_keys rmprimary_key_from_instancez Mapper.primary_key_from_instance s;))(344 ;** Arlc|jDcgc]}|jjc}tj dgrfd}|Sd}|Scc}w)NcVtdt|jdDS)Nc3:K|]\}}|||n|ywrhrk)rVkey_fnvals rmrXz=Mapper._persistent_sortkey_fn..key.. s*#$*#5F3K3>sr)rzipr$)rkey_fnss rmr$z*Mapper._persistent_sortkey_fn..key s,'*7EIIaL'Arlc |jdSNrrS)rs rmr$z*Mapper._persistent_sortkey_fn..key syy|#rl)r}rsort_key_functionrj difference)rrkr$rs @rm_persistent_sortkey_fnzMapper._persistent_sortkey_fn sU9=9I9IJ#388--J w< " "D6 *   $ KsAcZ|jDcgc]}|j|c}Scc}wrh)r}rrrks rmrizMapper._identity_key_props s'7;7G7GH&&s+HHHs(cxt}|jD] }|j|j|"|Srh)rjrrr)r collectionrs rm _all_pk_colszMapper._all_pk_cols s;-0U [[ 9E   d007 8 9rlc~t|j}|j|j|j|Srh)rjr}rrf)rrWs rm_should_undefer_in_wildcardz"Mapper._should_undefer_in_wildcard s5(+D,<,<(=    * HHT(( ) rlcn|jDchc]}|j|jc}Scc}wrh)rrr$rs rm_primary_key_propkeyszMapper._primary_key_propkeys s-;?;L;LMC&&s+//MMMs 2c|j|}|j|jjj |||SNr)rrCr$rr~rrrrrr%s rm_get_state_attr_by_columnz Mapper._get_state_attr_by_columns?%%f-}}TXX&++//ug/NNrlc|j|}|j|jjj |||yrh)rrCr$rset_committed_valuerrrrrr%s rm#_set_committed_state_attr_by_columnz*Mapper._set_committed_state_attr_by_column s7%%f- dhh$$88uMrlc|j|}|j|jjj |||dyrh)rrCr$rrjrs rm_set_state_attr_by_columnz Mapper._set_state_attr_by_columns9%%f- dhh$$((udCrlctj|}tj|}|j|||tj Sr)rr instance_dict#_get_committed_state_attr_by_columnr&r)rrrrrs rm_get_committed_attr_by_columnz$Mapper._get_committed_attr_by_columnsI))#.((-77 5&+*A*A8  rlc|j|}|j|jjj |||Sr)rrCr$rget_committed_valuers rmr z*Mapper._get_committed_state_attr_by_columnsG%%f-}}TXX&++?? 5'@  rlc Xj}t|jjjj }tt |Dcgc]-}||jD]}tj|d/c}}jjvryfd}g}d} ttjD]} | jvrd} n&t| jt j"sy| s=| j$rJ| j&sJ| j(rJ| j*J|j-| j*j/| j t1j2|did|i} | |d<t7j8|} g} |D] }| j;||j"t7j<| j?| jAtBScc}}w#t4$rYywxYw)alassemble a WHERE clause which retrieves a given state by primary key, using a minimized set of tables. Applies to a joined-table inheritance mapper where the requested attribute names are only present on joined tables, not the base table. The WHERE clause attempts to include only those tables to minimize joins. T) check_columnsNcd|j}|j}||y|jvr{jj|t j }|tjvr ttjd||jj|_y|jvr{jj|t j }|tjvr ttjd||jj|_yy)Nrr) rrrr rr&PASSIVE_NO_INITIALIZEr _none_set_OptGetColumnsNotAvailabler5rr)rleftcolrightcolleftvalrightvalrrrs rmrz5Mapper._optimized_get_statement..visit_binary?s kkG||H("2}}F*BBJJ'== C h000466!mm'):): v-CCJJ'== D x111466"}}(&,,*;*;  .rlFrr)"rrjrerrrrrrr`rr|reversedrrrr:r=rrrrr rfr>cloned_traverserr5rrselectwhereset_label_stylerC)rrattribute_namespropscol_attribute_namesr$rrallcondsstartr _traversedcondrWrs`` @rm_optimized_get_statementzMapper._optimized_get_statement#s !/2?? LL % % * * , #&  3"3Z//(($?? #     ' '6 1 >/1 tD$8$8$:;< /F!!V+ 2 2J4J4JKV]]&!??**//;;; 8 89 6--. /  %!11 R(L!9J %HQKxx"& ,C KKc ** + , JJ  U4[ _; < _J*  s2H H H)(H)c#K|j|r8|}|jD]"}|||ur||jvry|}||us"yyywrh)rrr.)rrprevrs rm_iterate_to_target_viawpolyz"Mapper._iterate_to_target_viawpolys_ 88F D))+ D=T1L1L%L;  s AA A ciSrhrkrs rm&_would_selectinload_combinations_cachez-Mapper._would_selectinload_combinations_caches rlc|j} ||S#t$rYnwxYw|j|sJ|}|j|D]}|jdk(s||u}nd}|||<|S)areturn True if this mapper would "selectin" polymorphic load based on the given super mapper, and not from a setting from a subclass. given:: class A: ... class B(A): __mapper_args__ = {"polymorphic_load": "selectin"} class C(B): ... class D(B): __mapper_args__ = {"polymorphic_load": "selectin"} ``inspect(C)._would_selectin_load_only_from_given_mapper(inspect(B))`` returns True, because C does selectin loading because of B's setting. OTOH, ``inspect(D) ._would_selectin_load_only_from_given_mapper(inspect(B))`` returns False, because D does selectin loading because of its own setting; when we are doing a selectin poly load from B, we want to filter out D because it would already have its own selectin poly load set up separately. Added as part of #9373. rF)r,rNrr*r)r super_mappercacherrretvals rm+_would_selectin_load_only_from_given_mapperz2Mapper._would_selectin_load_only_from_given_mappers@;; & &   xx %%%11&9 A!!Z/l*  F$l s  cx|s,|}|j|D]}|jdk(s|cSyt|}|Dcic]}|j|}}|j |gD]M}|j}|j|D]+}|jdk(s||vs|j ||ccSOycc}w)Nr)r*rrjrrBr~)renabled_via_optpolymorphic_fromrreenabled_via_opt_mappersrs rm_should_selectin_loadzMapper._should_selectin_loads%F55f= %%3H  "/2O|jAtB}|jDjG| } | Dcgc]}|jDjG|} }|jI| jKt7jLd d jN| }njt7j>|jAtB}|jI| jKt7jLd d jN| }|||fScc} wcc}w) zbAssemble a that can load the columns local to this subclass as a SELECT with IN. rT)_reconcile_to_other do_nothingF _orm_adaptrr primary_keys) expanding)(r!rorm_strategy_optionsrrrrjriLoadrrfrrr$rrrr._set_generic_strategyrrer strategy_keyr}r_deep_annotatergr5tuple_is_aliased_classrrrrC_adapterrrr%rorder_by)rrr4strategy_optionspolymorphic_prop keep_props disable_opt enable_optclasses_to_includerr%pkr}in_exprqrps rm_subclass_load_via_inzMapper._subclass_load_via_ins6 >>>>}}}    *#55d6I6IJ ./$2J2JJKJT556J&++F3 %**62 "V#'== M))""j0  " "1 % A M))""j0 %%(:(:: Dxxt111{{00DJ4F"$(;<'==V44dhh?A**+(, > *??V44dhh?A!4((- @ 3 H&&   # #Bt(< =   { a jj+.G!!nG  " "==D( (( 6"22.Aoo..w7G@KL16??33A6LKL CMM.DIJh %A 4 00.A CMM.DIJh %A*k))A (Ms M"Mc:|j||jSrh)rPrrs rm_subclass_load_via_in_mapperz#Mapper._subclass_load_via_in_mapperJs))$0@0@AArlc #Kt}tt}}|jj|sJt t |jj j |||jfg}|r|d\}} } } |s|j| |uri|j} | jr|| jvrN| J| Jt | j|| | ||} | rm|j| |ddfnW| |urS|j\}}}}||||f|jt |j j |||f|ryyw)a.Iterate each element and its mapper in an object graph, for all relationships that meet the given cascade rule. :param type\_: The name of the cascade rule (i.e. ``"save-update"``, ``"delete"``, etc.). .. note:: the ``"all"`` cascade is not accepted here. For a generic object traversal function, see :ref:`faq_walk_objects`. :param state: The lead InstanceState. child items will be processed per the relationships defined for this object's mapper. :return: the method yields individual object instances. .. seealso:: :ref:`unitofwork_cascades` :ref:`faq_walk_objects` - illustrates a generic function to traverse all objects without relying on cascades. rN) rjobjectrrrrrrrKrrcascade_iteratorr )rrrhalt_onvisited_statesprpmpp visitablesiterator item_type parent_state parent_dictr%queuerinstance_mappercorresponding_statecorresponding_dicts rmrUzMapper.cascade_iteratorOs@36%8VXS||%%%ELL''..013uzz J K =G^ :Hi{ C'')||uDLL'@#///"...))$#& %%uc4&>?c! $$& #'&#'&  !!o44;;=>+* Is E&E+)E+c@tj|jSrh)r!LRUCacherrs rm_compiled_cachezMapper._compiled_caches}}T6677rlc2t|jdkDSr)rgrrs rm_multiple_persistence_tablesz#Mapper._multiple_persistence_tabless4;;!##rlc i |jjD]%}|jD]} j||'g} j D]?\}}|j }|s|j |jDcgc]}||fc}A fd}tj ||}tj} |D] } || |< | Scc}w)Ncj|jj}j|jj}||||ur|jt t j|j}|jL|jt j|j}|j|vxr|j|vS|j|vSyr2) r~rrrrrjr _find_columnsrB)fkrdeprWtable_to_mappers rmskipz#Mapper._sorted_tables..skips %((9F!%%biioo6C"Ov%))5811#2G2GHI++7:: ..v/G/GHD99D0JRYYd5JJ99D00rl)skip_fnextra_dependencies) rrr setdefaultr rrr sort_tablesr!rz) rrrWrprsuper_ super_tablernsorted_retrms @rm_sorted_tableszMapper._sorted_tabless:<&&;; 6F]] 6**1f5 6 6 ,224 ME6__F"))=C]]Kkk5)K  0&& 1    (A$Q'CF ( ILs C c||jvrtt|j|S|x|j|<}|Srh)rr r_)rr$ callable_rs rm_memoz Mapper._memosD $'' 'D11#67 71: .set_unions771: rl) r! defaultdictrrwrjrrrrerrbr )rrbr~rrWrrrs rm_table_to_equatedzMapper._table_to_equateds   T "  (( IEuwwrArErGrKrPrrZrcmemoized_instancemethodrlrprrsrvr|rrxrurrrrrerrrrrrrrr!rrrrrrrrrrrrrr&PASSIVE_RETURN_NO_VALUErrrrirrrrrr rr r'r*r,r1r7rPrRrUrergrwrzrrkrlrmrurusf %$O"s" T  -1BFGK!<@GK $@D  =A.2:>%*DH"&'+6:6: $ %%)7=!&$'I^ B^ B*^ B@ ^ B E ^ B  ^ B:^ BE^ B ^ B^ B>^ B ^ B" #^ B(;)^ B*,+^ B,-^ B.8/^ B0#1^ B2B3^ B4 5^ B67^ B8%9^ B:4;^ B<4=^ B>?^ B@A^ BB#C^ BD5E^ BFG^ BH"I^ B ^ B@ ' I%!  A00552277!!((BBDD 6644%%LL% "! DC00PO0#"2$# 54J N0/.$# L65 ,+ ('  87 214 T__U56'7 ' --}~%( =%( %(NA61[z5.} ~rhD2L&*"##$ ## $ ##/$/T:;<8T:; "'h hFh  h  h h h<hT9 9 9  9H8<;? @ @+@ @ 5 @ 9 @ @DT:;" "("  "<"H --    A  A.***E* *")    CDI  ("49,0 ".'. .** ""%9" "H,9= :##$"## $ ##  $  ##. $. `##?$?##  $  ' '  9 ' ' ##  $  ## $ ## $ ## $ ## 4 $ $## 4 $ $## $ ## , $ ##$ (( ) .    1 1>C NN<N N 2 N0## $       ## $ 8###4$#4J##C $C J##T:; <$ ##T:; I<$ I## B$ B##T78 ; 9$ :##T:;  <$    % ## $ $##"$"H ?##D$D,\5  -'-9=- - ## .$ . /) 55  )-(, ! (! &! & !  ! L)- $ &    "M& +BB       $ ##$$##I$I##$ ##$ ##N$N +BB O OO# O  O OND -8,O,O d L ##$6p,T:;_*<_*B##B$BCG __!_@ _   _B##8$8##$$$##0$0d rlrurc eZdZy)rN)rrrrkrlrmrrsrlrc.ttdy)a Initialize the inter-mapper relationships of all mappers that have been constructed thus far across all :class:`_orm.registry` collections. The configure step is used to reconcile and initialize the :func:`_orm.relationship` linkages between mapped classes, as well as to invoke configuration events such as the :meth:`_orm.MapperEvents.before_configured` and :meth:`_orm.MapperEvents.after_configured`, which may be used by ORM extensions or user-defined extension hooks. Mapper configuration is normally invoked automatically, the first time mappings from a particular :class:`_orm.registry` are used, as well as whenever mappings are used and additional not-yet-configured mappers have been constructed. The automatic configuration process however is local only to the :class:`_orm.registry` involving the target mapper and any related :class:`_orm.registry` objects which it may depend on; this is equivalent to invoking the :meth:`_orm.registry.configure` method on a particular :class:`_orm.registry`. By contrast, the :func:`_orm.configure_mappers` function will invoke the configuration process on all :class:`_orm.registry` objects that exist in memory, and may be useful for scenarios where many individual :class:`_orm.registry` objects that are nonetheless interrelated are in use. .. versionchanged:: 1.4 As of SQLAlchemy 1.4.0b2, this function works on a per-:class:`_orm.registry` basis, locating all :class:`_orm.registry` objects present and invoking the :meth:`_orm.registry.configure` method on each. The :meth:`_orm.registry.configure` method may be preferred to limit the configuration of mappers to those local to a particular :class:`_orm.registry` and/or declarative base class. Points at which automatic configuration is invoked include when a mapped class is instantiated into an instance, as well as when ORM queries are emitted using :meth:`.Session.query` or :meth:`_orm.Session.execute` with an ORM-enabled statement. The mapper configure process, whether invoked by :func:`_orm.configure_mappers` or from :meth:`_orm.registry.configure`, provides several event hooks that can be used to augment the mapper configuration step. These hooks include: * :meth:`.MapperEvents.before_configured` - called once before :func:`.configure_mappers` or :meth:`_orm.registry.configure` does any work; this can be used to establish additional options, properties, or related mappings before the operation proceeds. * :meth:`.MapperEvents.mapper_configured` - called as each individual :class:`_orm.Mapper` is configured within the process; will include all mapper state except for backrefs set up by other mappers that are still to be configured. * :meth:`.MapperEvents.after_configured` - called once after :func:`.configure_mappers` or :meth:`_orm.registry.configure` is complete; at this stage, all :class:`_orm.Mapper` objects that fall within the scope of the configuration operation will be fully configured. Note that the calling application may still have other mappings that haven't been produced yet, such as if they are in modules as yet unimported, and may also have mappings that are still to be configured, if they are in other :class:`_orm.registry` collections not part of the current scope of configuration. TrN)rrnrkrlrmconfigure_mappersrsH/+T:rlc|D]}|jsnyt5tr dddyda |D]}|jsn  dadddytjj tj t||da dddtjj tjy#dawxYw#1swYBxYw)NTF) rri_already_compilingrurv _for_classbefore_configured_do_configure_registriesafter_configured) registriesrrqs rmrr^s      '  ''" '! ## "' +'' OO & &v . @ @ B %Z 9!& +', OOv&779"' +''s9CCC C C=C C CCCzsqlalchemy.orm.decl_apichtjjj}t |}|j |D]5}d}|j D]}d}|jjD]!}|||j}|tusd}n|turHt|ddr8tjd|d|j} |j| _| |jr |j!|j#|jj%||j|sd|_|r|j0j3|s#tjdy#t&$r,t)j*d} t-| ds| |_wxYw)NFTrwzsOne or more mappers failed to initialize - can't proceed with initialization of other mappers. Triggering mapper: 'z'. Original exception was: rzHconfigure was called with cascade=False but additional registries remain)r!r orm_decl_apirKrj_recurse_with_dependenciesrprvbefore_mapper_configuredrzr)rrr5rwrrrmapper_configured Exceptionsysexc_infor>r _dependenciesr) rrrKorigrqhas_skipr run_configurefnr5rs rmrrs~~**33H z?D2x22:>*//1 F Moo>>  "66== 9  H,#H   (v2E:.. v77 9'-&>&>#$$557//1OO55ffmmL5 @$C 3,,77=,,/ O*<!,,.+C"3(;<360 s 3AE<<5F1ctjjj}t |}|j |D]}|s0|j j|rtjd|jr< |jj\}}|j||jr<|jj|j j|j D]}|j j#||j jd|_y#t$rYwxYw)Nz^Registry has dependent registries that are not disposed; pass cascade=True to clear these alsoF)r!rrrKrj_recurse_with_dependents _dependentsrrr5 _managerspopitem_dispose_manager_and_mapperrN_non_primary_mappersclearrdiscardr)rrrKrrqrC_rls rm_dispose_registriesrs ~~**33H z?D0x00<!3??55d;,,8  mm 9 ]]224  //8mm   &&( $$ )C OO # #C ( ) ! !3!  sE EEcd|_|S)aDecorate a method as the 'reconstructor' hook. Designates a single method as the "reconstructor", an ``__init__``-like method that will be called by the ORM after the instance has been loaded from the database or otherwise reconstituted. .. tip:: The :func:`_orm.reconstructor` decorator makes use of the :meth:`_orm.InstanceEvents.load` event hook, which can be used directly. The reconstructor will be invoked with no arguments. Scalar (non-collection) database-mapped attributes of the instance will be available for use within the function. Eagerly-loaded collections are generally not yet available and will usually only contain the first element. ORM state changes made to objects at this stage will not be recorded for the next flush() operation, so the activity within a reconstructor should be conservative. .. seealso:: :meth:`.InstanceEvents.load` T)r0)rs rm reconstructorrs4#B IrlTinclude_removesinclude_backrefscdfd }|S)aDecorate a method as a 'validator' for one or more named properties. Designates a method as a validator, a method which receives the name of the attribute as well as a value to be assigned, or in the case of a collection, the value to be added to the collection. The function can then raise validation exceptions to halt the process from continuing (where Python's built-in ``ValueError`` and ``AssertionError`` exceptions are reasonable choices), or can modify or replace the value before proceeding. The function should otherwise return the given value. Note that a validator for a collection **cannot** issue a load of that collection within the validation routine - this usage raises an assertion to avoid recursion overflows. This is a reentrant condition which is not supported. :param \*names: list of attribute names to be validated. :param include_removes: if True, "remove" events will be sent as well - the validation function must accept an additional argument "is_remove" which will be a boolean. :param include_backrefs: defaults to ``True``; if ``False``, the validation function will not emit if the originator is an attribute event related via a backref. This can be used for bi-directional :func:`.validates` usage where only one validator should emit per attribute operation. .. versionchanged:: 2.0.16 This paramter inadvertently defaulted to ``False`` for releases 2.0.0 through 2.0.15. Its correct default of ``True`` is restored in 2.0.16. .. seealso:: :ref:`simple_validators` - usage examples for :func:`.validates` c*|_d|_|S)Nr)r2rA)rrrnamess rmwrapzvalidates..wraps"$. 0% ! rlrrcrrcrk)rrrrs``` rm validatesrsP Krlc|jj}|jr |j|jyyrh)rCrrr)rctxinstrumenting_mappers rmr@r@(s4 ==//**++EIIK8+rlc|jj}|r/|j|jr|j|yyy)zRun init_instance hooks. This also includes mapper compilation, normally not needed here but helps with some piecemeal configuration scenarios (such as in the ORM tutorial). N)rCrrr)rrkwargsrs rmr<r</sD!==//--/  9 9 : :5 A :rlc eZdZdZdZdZdZy)rz4Error reporting helper for mapper._columntoproperty.rc||_yrhrrs rmrz_ColumnMapping.__init__Ds  rlc .|jjj|}|rItjd|j j d|j d|jd|tjd|d|jd)NzColumn 'rz1' is not available, due to conflicting property 'z':z No column z is configured on mapper z...)rrr~orm_excUnmappedColumnErrorrrFr$)rrr%s rm __missing__z_ColumnMapping.__missing__Hsx{{!!%%f- --<<$$fkk6::tE  ))t{{ $  rlN)rrrr __slots__rrrkrlrmrr?s>I  rlr)rrb)rz Set[registry]rr)rzSet[_RegistryType]rr~rrr)rrrr~rr~rzCallable[[_Fn], _Fn])r __future__r collectionsr functoolsr itertoolsrr threadingtypingrrr r r r r rrrrrrrrrrrrrweakrefrurrrrrr r!r_typingr"r8r#r$r%r&r' interfacesr(r)r*r+r,r-r. path_registryr/r1rr2r3r4r5r6r7rxr9r:r;r<r=rr> sql.cache_keyr? sql.elementsr@ sql.schemarArBsql.selectablerCrDrE util.typingrFrGrHrIrJdecl_apirK dependencyrLrrMrNeventsrOrPrQrRrrSrrTrUenginerVrW sql._typingrXrYsql.baserZr[r\r]r^r_rarc_WithPolymorphicArgWeakKeyDictionaryrfrrnrrrsymbolrsRLockri_self_inspects class_logger Identified Inspectablerurrrrrrrrrr@r<rrkrlrmrsS#  "(( &&2)+'""/-;4!)&/&"/31$-4*3$ #723+,+! T e01 e/0 CL  gclHU=$s)+C%DEEF  U=$s)+ ,- /GB ' /  t{{>* #9??$ l=r"NN<( BKl=l=^{  D;N:":-1: :D./1"1-11 101h./!0!B>*/0 0"&0BF00f9 B  TEF rl