Sh3ll
OdayForums


Server : LiteSpeed
System : Linux premium84.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : claqxcrl ( 523)
PHP Version : 8.1.32
Disable Function : NONE
Directory :  /opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/orm/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/orm/__pycache__/mapper.cpython-312.pyc
�

���g����>�UdZddlmZddlmZddlmZddlmZddl	Z	ddl
Z
ddlmZddlm
Z
dd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddl 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!m<Z<d0dl!m#Z=d0d2l!m>Z>d0d3l!m?Z?d0d4l!m@Z@d0d5l!mAZAd0d!l!m(Z(d0d6l<mBZBd0d7l<mCZCd0d8lAm,ZDd0d9lAmEZEd0d:lAmFZFd0d;lAmGZGd0d<lAmHZHd0d=lAmIZId0d!lAm(ZJd0d>lAmKZKd0d?lLmMZMd0d@lNmOZOd0dAlPmQZQd0dBlPmRZRd0dClSmTZTd0dDl(mUZUd0dEl(mVZVd0dFlWmXZXer�ddGl*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 j��Zdhe�di<d�dj�Z�d�dk�Z�dla�e(�jdm�Z�e
�j�Z�e>�je?�jGdn�doe8e7e+eMe5e?�je>�jdpeCee+�
��Z�Gdq�dre��Z�d�ds�Z�						d�dt�Z�e(�j"du�						d�dv��Z�e(�j"du�d�dw��Z�dx�Z�dldydz�							d�d{�Z�d|�Z�d}�Z�Gd~�ded��Z�y)�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�_MP�MapperProperty[Any]�_FnzCallable[..., Any]�*�Mapper[Any]r]z.weakref.WeakKeyDictionary[_RegistryType, bool]�_mapper_registriesc�X�t5tt�cddd�S#1swYyxYw�N)�_CONFIGURE_MUTEX�setrf���F/opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/orm/mapper.py�_all_registriesrn�s��	��%�&�
�	�	�s� �)c#�^K�t�D]}|j�Ed{����y7��wrh)rn�_mappers_to_configure)�regs rm�_unconfigured_mappersrr�s(����� ���,�,�.�.�.�!�.�s�!-�+�-F�NO_ATTRIBUTEc�:�eZdZUdZded<dZdZded<dZejd��																												d�																																																									d�d��Z
d�Zd �Zd
Z
	dZd!ed"<ed�d#��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(dVdW�dX���Zej,d�dY��ZdZ�Z				d�d[�Zd\�Zd]�Zd^�Zd_�Zd�d`�Zd�da�Zd�db�Z d�dc�Z!d�dd�Z"d	Z#e$jJde��Z&e$jJdf��Z'e$jJdg��Z(ejRdh�di��Z*ejRdh�d
d
ddj�											d�dk��Z+						d�dl�Z,		d�											d�dm�Z-ejRdh�						d�dn��Z.ej^jadoe1jd�d�dp��Z3d�dq�Z4dr�Z5						d�ds�Z6d�dt�Z7ed�du��Z8d�dv�Z9d�dw�Z:d�dx�Z;d�dy�Z<d�dz�Z=d�d{�Z>	d�					d�d|�Z?				d�d}�Z@ed~��ZA						d�d�ZB						d�d��ZCe$jJd�d���ZDe$jJd���ZEe$jJd���ZFe$jJd���ZGe$jJd�d���ZHe$jJd���ZIeJd�d���ZKeHZL	eJd���ZMe$jJd���ZNe$jJd���ZOe$jJd���ZPe$jJd���ZQe$jJ		d�d���ZRe$jJ		d�d���ZSe$jJd�d���ZTe$jJ		d�d���ZUe$jJd�d���ZVe$j�d���ZXej,d���ZYed�d���ZZ			d�							d�d��Z[e$jJd���Z\ed���Z]d�d��Z^e$jJd�d���Z_d�d��Z`e$jJd�d���Zae$jJd�d���Zbe$jJejRdh�d�d����Zce$jJejRdh�d�d����Zded���Zee$jJd�d���Zfe$jJejRd��		d�d����Zge$jJejRdh�d�d����Zh				d�d��Zie$jJd���Zje$jJd�d���Zkd�d��Zle$jJd���Zmd��Znd�d��Zod�d��Zp						d�d��Zqd�d��Zrd�d��Zse$jJd�d���Ztd�d��Zud�d��Zved�d���Zwd�d��Zx		d�							�dd��Zy	d�					�dd��Zz�dd��Z{e|j�f					�dd��Z~�dd��Ze$jJd���Z�e$jJd���Z�e$jJd���Z�e$jJd���Z�e$jJd���Z�e|j�f									�dd��Z�d��Z�d��Z�d��Z�e|j�fd„Z�dÄZ�dĄZ�e$jJdń�Z�dƄZ�dDŽZ�ejRdȫdɄ�Z�e$jJdʄ�Z�	d�							�dd˄Z�e$jJd̄�Z�e$jJd̈́�Z�e$jJd΄�Z��ddτZ�ej,dЄ�Z�y	(�Mappera�Defines 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_primaryNT�class_�Type[_O]�local_table�primary_keyry�bool�inherits�inherit_condition�always_refresh�version_id_col�version_id_generator�5Optional[Union[Literal[False], Callable[[Any], Any]]]�polymorphic_on�polymorphic_identity�
Optional[Any]�concrete�with_polymorphic�allow_partial_pks�
Optional[str]c�v�tj|td�|_|jj�d|jj
��|_tj|�|_||_	|	|_
t|
t�r|
|_
d|_n/|
�&tj t"j$|
d��nd|_|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|_||_|rt?|�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��|j�j�|�|j�d�|j��ddd�|j|j�||j�y#1swY�0xYw)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 <orm_declarative_mapping>` or
        :ref:`Imperative <orm_imperative_mapping>` 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 <engine_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 <engine_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 ``(<classes>,
            <selectable>)`` indicating the default style of "polymorphic"
            loading, that is, which tables are queried at once. <classes> 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 <selectable>
            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�.Nr���argnameFc��|xsddzS)Nrrrk)�xs rm�<lambda>z!Mapper.__init__.<locals>.<lambda>�s��1�6��Q�,rlTr|)�disable_inspectionr��Mapper[zM(None)] has None for a primary table argument and does not specify 'inherits'r�rO�constructed)Kr!�assert_arg_type�typerz�
__module__�__name__�	_sort_key�to_list�_primary_key_argumentryr��
isinstancer+�version_id_propr�r9�expectr<�ColumnArgumentOrKeyRoler�r��singler$r�StrictFromClauseRoler|�sa_exc�
ArgumentError�OnClauseRoler��inherit_foreign_keys�dict�_init_properties�_delete_orphans�batch�eager_defaults�
column_prefixr��polymorphic_abstract�_dependency_processors�
EMPTY_DICT�
validators�passive_updates�passive_deletes�legacy_is_orphan�_clause_adapter�_requires_row_aliasing�_inherits_equated_pairs�_memoized_values�_compiled_cache_size�_reconstructorr��confirm_deleted_rows�_set_with_polymorphic�polymorphic_loadr��polymorphic_map�to_set�include_properties�exclude_propertiesrir	rv�_events�_new_mapper_instance�_configure_inheritance� _configure_class_instrumentation�_configure_properties�_configure_polymorphic_setter�_configure_pksrK�_flag_new_mapper�_log�_expire_memoizations�after_mapper_constructed)�selfrzr|r r}ryrr�r�r�r�r�r��_polymorphic_mapr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�s                              rm�__init__zMapper.__init__�s���r�*�*�6�4��B����K�K�"�"��K�K� � �
���
&*�\�\�+�%>��"�&���,����n�n�5�#1�D� �"&�D��"�-�� � ��1�1�"�,���
�� �5�(�(-�D�%�
!�
)�(>�D�%�(<�D�%� ��
������2�8�<�D�M� �D�M��"�(�/�/��*�*��#'�%�	 �D���]�]� $�}�}�8�8�D���D�K��&�&��$�+�+�.�.�/�0I�I��
�
�(�%.�%5�%5��"�"�$5�&�D�"�&*�D�"�$8��!�4>��Z� 0�B���!�����
�,���*����)�
����-�-��(�
��	
��%9��!�&(��#��/�/���.���.��� 0���#���&+��#�'+��$� "���$8��!�"���!2����=�=����(-�D�%�(<�D�%��"�"�#3�4� 0���
%9��!�
�#�#%�D� �#3�D� ��)�&*�k�k�2D�&E�D�#�&*�D�#��&*�k�k�2D�&E�D�#�&*�D�#�
������!6�!6�7�L�L���
�
�'�'�)��1�1�3��&�&�(��.�.�0����!��M�M�*�*�4�0��I�I�m�$��%�%�'��	
�
�
�.�.�t�T�[�[�A��
�s
�B=P/�/P8c��|jdk(r)|jsy||jvxr|jS|jS)N�autoF)r��implicit_returning�_server_default_col_keys�insert_executemany_returning)r��dialect�tables   rm�_prefer_eager_defaultszMapper._prefer_eager_defaultsisM�����&�(��+�+����6�6�6�9��8�8�
�
�&�&�&rlc��|fSrhrk)r��anon_map�
bindparamss   rm�_gen_cache_keyzMapper._gen_cache_keyus	���w�rlrJrKc��|S)z<Part of the inspection API.

        Returns self.

        rk�r�s rm�mapperz
Mapper.mapper�s	���rlc��|jS)zDPart of the inspection API.

        Returns self.class\_.

        �rzr�s rm�entityz
Mapper.entity�s���{�{�rl�_identity_classzList[Tuple[str, Type[Any]]]r�zList[DependencyProcessor]r�zDict[Any, Callable[[], Any]]r�zutil.WeakSequence[Mapper[Any]]�_inheriting_mapperszSet[TableClause]�_all_tables�_polymorphic_attr_keyz/Dict[FromClause, OrderedSet[ColumnClause[Any]]]�
_pks_by_tablez0Dict[FromClause, OrderedSet[ColumnElement[Any]]]�_cols_by_tablez*util.OrderedDict[str, MapperProperty[Any]]�_propszDict[str, MapperProperty[Any]]r��_ColumnMapping�_columntopropertyz-Optional[Callable[[InstanceState[_O]], None]]�_set_polymorphic_identityzHOptional[Callable[[Mapper[_O], InstanceState[_O], _InstanceDict], None]]�_validate_polymorphic_identityzSequence[TableClause]�tablesz3util.immutabledict[str, Tuple[str, Dict[str, Any]]]r�zOptional[ColumnElement[Any]]zcOptional[Tuple[Union[Literal['*'], Sequence[Union[Mapper[Any], Type[Any]]]], Optional[FromClause]]]r]�persist_selectablezOptional[Mapper[Any]]zOptional[ColumnElement[bool]]�
configuredzTuple[Column[Any], ...]zClassManager[_O]�
class_managerr��!Optional[KeyedColumnElement[Any]]zDict[Any, Mapper[Any]]r�re�base_mapperz*ReadOnlyColumnCollection[str, Column[Any]]�columns�crxzUse .persist_selectablec��|jSrh)r�r�s rm�mapped_tablezMapper.mapped_table�s���&�&�&rlc�,�tj|�Srh)r/�
per_mapperr�s rm�_path_registryzMapper._path_registry�s���&�&�t�,�,rlc���tj�|_|j�r#t	|j
|jj
�sNt
jd|j
j�d|jj
j�d���|jj|jj�|j|jjk7rH|jxrdxsd}t
jd|�d|j
j�d|�d	���|jr|jj|_
�nn|j|jju�r:|jr<|j|_
|j!�D]}|j"��d|_��n|j&�:	t)j*|jj|j�|_|jj�J�t3j4|jj|j|j&�|_
tj6|j8�}t)j:|jj<|��|_n|j|_
|j@�w|j
|_!|jDs�|jjFj"�stjH|�d|jjFj"�d��n9|jr|j
|_!n|jjB|_!|jJ�7|jjJ|_%|jjL|_&n�|jjJ�p|jJ|jjJurNtjHd|jJj.�d|jjJj.�d��|jjN|_'|jjP|_(|jjjS|�|jjF|_#|jjT|_*|jjVxs|jV|_+|jjX|_,|j@�~|j@|jNvrMtjHd|j@�d|jN|j@�d|�d|j@�d�	�||jN|j@<|jZr!|jrt
jd��|jZdk(r|jj]|�n�|jZdk(rn�|jZ��t
jd|jZz��t_�|_,||_#|j�J�|j|_
|j@�||jN|j@<|j
|_!|j�t
jd|z��y
#tj,$rz}|jj�J�|j�J�t
j,d|jjj.�d
|jj.�d��|�d
}~wtj0$rz}|jj�J�|j�J�t
j0d|jjj.�d
|jj.�d��|�d
}~wwxYw) zXConfigure settings related to inheriting and/or inherited mappers
        being present.zClass 'z' does not inherit from '�'�primaryznon-primaryzInheritance of z mapper for class 'z' is only allowed from a z mapperNTz?Can't determine the inherit condition between inherited table 'z' and inheriting table 'z�'; tables have no foreign key relationships established.  Please ensure the inheriting table has a foreign key relationship to the inherited table, or provide an 'on clause' using the 'inherit_condition' mapper argument.z�'; tables have more than one foreign key relationship established.  Please specify the 'on clause' using the 'inherit_condition' mapper argument.)�consider_as_foreign_keysz| does not indicate a 'polymorphic_identity', yet is part of an inheritance hierarchy that has a 'polymorphic_on' column of 'a''. If this is an intermediary class that should not be instantiated, the class may either be left unmapped, or may include the 'polymorphic_abstract=True' parameter in its Mapper arguments. To leave the class unmapped when using Declarative, set the '__abstract__ = True' attribute on the class.zInheriting version_id_col 'z+' does not match inherited version_id_col 'z�' and will not automatically populate the inherited versioning column. version_id_col should only be specified on the base-most mapper that includes versioning.z1Reassigning polymorphic association for identity z from z to z: Check for duplicate use of z# as value for polymorphic_identity.zKpolymorphic_load is not currently supported with concrete table inheritance�inline�selectinz)unknown argument for polymorphic_load: %rz9Mapper '%s' does not have a persist_selectable specified.)0r!�WeakSequencer�r�
issubclassrzr�r�r�rv�_updateryr�r�r|r��iterate_to_rootr�r�r��sql_util�join_condition�NoForeignKeysError�description�AmbiguousForeignKeysErrorr5�joinr�r��criterion_as_pairs�onclauser�r�r�r�r��warnr�r�r�r��appendr�r�r�r��_add_with_polymorphic_subclassrj)r��npr��nfe�afe�fkss      rmr�zMapper._configure_inheritance�sm��
$(�#4�#4�#6�� ��=�=��d�k�k�4�=�=�+?�+?�@��*�*��{�{�+�+�T�]�]�-A�-A�-J�-J�L���

�M�M�!�!�$�-�-�"8�"8�9����4�=�=�#<�#<�<��)�)�)�7�i�H�=���*�*��4�;�;�/�/��5����{�{�*.�-�-�*J�*J��'��!�!����)B�)B�B��=�=�.2�.>�.>�D�+�"&�"6�"6�"8��!�0�0�<�<@�F�9�#9��-�-�5�
''�5=�5L�5L� $�
�
� 9� 9�4�;K�;K�6�D�2�N �=�=�;�;�G�G�G�.1�h�h��
�
�8�8��(�(��.�.�/�D�+��+�+�d�&?�&?�@�C�3;�3N�3N��/�/�8�8�14�4�D�0�
+/�*:�*:��'��(�(�0�'+�{�{��$��1�1��
�
�1�1�@�@�L��I�I��&�!�!�M�M�5�5�D�D�E�FH�	H�����'+�{�{��$�'+�}�}�'D�'D��$��"�"�*�&*�m�m�&B�&B��#�,0�M�M�,N�,N��)��
�
�,�,�8��'�'�t�}�}�/K�/K�K��	�	��+�+�7�7��
�
�4�4�@�@��
�$(�=�=�#@�#@�D� ����,�,�D�J��M�M�-�-�4�4�T�:�#�}�}�8�8�D��#'�=�=�#@�#@�D� ��
�
�-�-�E��1E�1E�
� � $�}�}�8�8�D���(�(�4��,�,��0D�0D�D��I�I�
!�5�5� �0�0��1J�1J�K� � �5�5��
�CG��$�$�T�%>�%>�?��$�$�����*�*�6����$�$��0��
�
�<�<�T�B��&�&�*�4���&�&�2��*�*�?��+�+�,��� #�u�D��#�D���#�#�/�/�/�&*�&6�&6�D�#��(�(�4�BF��$�$�T�%>�%>�?�#'�;�;�D� ��"�"�*��&�&�K����
�+��_ &�8�8�'�#'�=�=�#<�#<�#H�H�#H�#'�#3�#3�#?�?�#?�"(�";�";�%)�M�M�$=�$=�$I�$I�$(�$4�$4�$@�$@�!"�#� $'�!'��" &�?�?�'�#'�=�=�#<�#<�#H�H�#H�#'�#3�#3�#?�?�#?�"(�"B�"B�%)�M�M�$=�$=�$I�$I�$(�$4�$4�$@�$@�
!"�#�$'�'��'�s&�9[�_2�-A5]"�"_2�8A5_-�-_2c��|dk(rd|_nqt|ttf�r:t|dtttf�rtd|�|_n+|df|_n!|�t
jd|����d|_|jrV|jd�G|jdtjtj|jdd��f|_|jr|j�yy)	Nrd)rdNrz�Tuple[
                        Union[
                            Literal["*"],
                            Sequence[Union["Mapper[Any]", Type[Any]]],
                        ],
                        Optional["FromClause"],
                    ]z&Invalid setting for with_polymorphic: rT��allow_select)r�r��tuple�list�strr	r�r�r9r�r<r�r�r�)r�r�s  rmr�zMapper._set_with_polymorphicms���s�"�$/�D�!�
�(�5�$�-�
8��*�1�-��U�D�/A�B�(,��%�	)��%�*:�4�(@��%�
�
)��&�&�8�9I�8L�M��
�%)�D�!�� � �T�%:�%:�1�%=�%I��%�%�a�(�� � ��.�.��)�)�!�,�!%��%�D�!��?�?��%�%�'�rlc� �|j}|j�|j|f�y|jddk7rQt|jdt�sJ�|j|jd|fz|jdf�yy)Nrrdr)rzr�r�r�r)r�r��subcls   rmr
z%Mapper._add_with_polymorphic_subclass�s����
�
��� � �(��&�&��x�0�
�
"�
"�1�
%��
,��d�3�3�A�6��>�>�>��&�&��&�&�q�)�U�H�4�d�6K�6K�A�6N�O�
�-rlc�L�|jsJ�|jrJ�t|t�sJ�||_|jjj|j�|jj|_|j
�D]}|j��d|_�|jj|_	|jD]}|jj|_�|jjj|�|jj|_|jj|_|j j#�D]=\}}||j vs�|j%||dd��r�+|j'||d��?y)z�Set 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.NTF��local�column)r�rr�rur��updaterr�r�r��self_and_descendantsr�r�rr�r�r��items�_should_exclude�_adapt_inherited_property)r�r��mp�key�props     rm�_set_concrete_basezMapper._set_concrete_base�sR��
�}�}��}��=�=� � ��&�&�)�)�)���
��
�
�%�%�,�,�T�-A�-A�B�#�}�}�<�<����*�*�,�F��$�$�0�04��-�-��]�]�(�(��
��+�+�B�!�]�]�6�6�B�N�,��
�
�)�)�0�0��6�#�}�}�<�<����=�=�4�4������,�,�.�I�C���$�+�+�%�d�.B�.B��S��d�/C�/��.�.�s�D�%�@�	/rlc�4�||_|jd�y)NT)r�r�)r�r�s  rm�_set_polymorphic_onzMapper._set_polymorphic_on�s��,����*�*�4�0rlc	�R�tj|j�}|jr�|r|js"tjd|jz��||_|j�J�|j|_|jj|_
|jj|�y|�|jstjd��|jj||j�tj|j|t!j"t$j&|�d��}||_|j�J�|j|_|j�yt)j*|dt,d��t!j.|j�D]�\}}|dk(r0t1|d	�r$|j2}t1|d
�r|j4}t7|�s�Gt1|d�r%||_t)j*|dt:d���xt1|d
�s��|j<}|j>D]P}||j@vrtjd|�d|�d���|j@jC|||fi�|_ �R��y)a�If 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.Nz�The _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)r��expired_attribute_loader�finalize�init)�rawr��_sa_original_init�__func__�__sa_reconstructor__�load�__sa_validators__z+A validation function for mapped attribute z on mapper z already exists.)"r�opt_manager_of_classrzry�	is_mappedr��InvalidRequestErrorr�rKr�r��_add_non_primary_mapperrv�instrument_classr�register_classr!�partialr�load_scalar_attributesr1�listen�_event_on_init�iterate_attributes�hasattrr.r/�callabler��_event_on_load�__sa_validation_opts__r2r��union)r��managerr$�method�validation_opts�names      rmr�z'Mapper._configure_class_instrumentation�sT���1�1�$�+�+�>������'�"3�"3��0�0�� $���,���
")�D���#�#�/�/�/�#�,�,�D�M�#*�>�>�#A�#A�D� ����4�4�T�:���?�'�"2�"2��,�,�4��
�	
�
�
�&�&�t�T�[�[�9�"�0�0��K�K��%)�\�\��.�.��&�
�	
��%������+�+�+��(�(��
��>�>�!��
���W�f�n�$�?��2�2�4�;�;�?�K�C���j� �W�V�5H�%I��1�1���6�:�.�#�_�_�F�����6�#9�:�*0�D�'��L�L��&�.�d�K��V�%8�9�&,�&C�&C�O� &� 8� 8���4�?�?�2�"(�"<�"<�$(��!/�#��
+/�/�/�*?�*?�!�F�O�#<�=�+���!9�@rlc�f�d|_d|_d|_|jj	dd�y)NTrw)r��_ready_for_configure�_dispose_called�__dict__�popr�s rm�_set_dispose_flagszMapper._set_dispose_flagss.�����$(��!�#����
�
���-�t�4rlc�P�	|j|}	|j}t
|t�stjd|�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)r��KeyErrorr�r�r:�AttributeErrorr�rA)r�r�r$r%�err�expr�aes       rm�_str_arg_to_mapped_colzMapper._str_arg_to_mapped_col!s���	��;�;�s�#�D�	��?�?�D��$��'��&�&�"�7�)�9�S�E�: � ��
�
���%�	��&�&�"�7�)�9�S�E�:7�7���
��	���	��&�&�"�7�)�9�S�E�:D�D���
��	�s.�A�A:�	A7�A2�2A7�:	B%�B � B%c�0	��tj�j��_�jjd��jD��i�_i�_tjt�jD�cgc]}|j��c}��}tjd�|D��}t�j�j�jg�D]�}|jrV|j!|j�r;tj"|j�j%|��j|<tj"|j&�j%|��j|<���j(rCd��j(D�D�cgc]&}t+|t,�r�j/d|�n|��(}}nd}|rs|D]m}|j0�jvr+tj2��j|j0<�j|j0j5|��onՉj�jvs%t7�j�j�dk(r0t9j:d��d�jj<�d����j>�jvrPt+�j>t@jB�r,tjDd	�j>j<z��jFr4�jHs(�j(s�jFj�_n�|r"�fd
�|D�D��cgc]\}}|�|n|��
}	}}n.tjJ�j�jd��}	t7|	�dk(r0t9j:d��d�jj<�d���tM|	��_�jOd
|	��jD�chc]P}�j|�jPvr3tS|d�r|j0�jvr�j|��Rc}�_*ycc}wcc}wcc}}wcc}w)Nc3� K�|]}|���y�wrhrk)�.0�ts  rm�	<genexpr>z(Mapper._configure_pks.<locals>.<genexpr>;s����7�;�a��;�s�c3�:K�|]}|js�|���y�wrh)r})rVr�s  rmrXz(Mapper._configure_pks.<locals>.<genexpr>Ds����!G�X�����!�X�s��c3�hK�|]*}tjtj|d�����,y�w)r}r�N)r9r�r<�DDLConstraintColumnRole)rV�	coerce_pks  rmrXz(Mapper._configure_pks.<locals>.<genexpr>[s=�����&@�	��$�$��5�5�!� -���
&@�s�02r}rzMapper z> could not assemble any primary key columns for mapped table 'r�zlCould not assemble any primary keys for locally mapped table '%s' - no rows will be persisted in this Table.c3�X�K�|]!}�jj|�|f���#y�wrh)r��corresponding_column)rVr�r�s  �rmrXz(Mapper._configure_pks.<locals>.<genexpr>�s/�����"�!/�A��0�0�E�E�a�H�!�L�!/�s�'*T)�ignore_nonexistent_tablesz"Identified primary key columns: %sr�)+r�find_tablesr�r�r�rr�r�r!�
column_setrr��	proxy_setrjrBr}�
issuperset�ordered_column_set�intersectionr�r�r�rrSr�r^�add�lenr�r�rr|r4rBrrr��reduce_columnsrr��_identity_key_propsr>�_readonly_props)
r��col�all_cols�pk_cols�fcr��coerced_pk_arg�k�ccr}s
`         rmr�zMapper._configure_pks8s����*�*�4�+B�+B�C��������7�4�;�;�7�7���� ����?�?��T�-C�-C�D�-C�c�C�M�M�-C�D�E�
���/�/�!G�X�!G�G���d�k�k�"�(�(�$�*A�*A�)B�C�B��~�~�'�"4�"4�R�^�^�"D�*.�)@�)@��N�N�*��,����"�"�2�&�
'+�&=�&=�b�d�d�&C�&P�&P��'�D����#�D��%�%��&*�%?�%?�
�
��A�"�!�S�)��/�/�
�q�A����

�� "�N��#���7�7�$�"4�"4�4�26�/�/�2C�D�&�&�q�w�w�/��"�"�1�7�7�+�/�/��2�$�
�#�#�4�+=�+=�=��4�%�%�d�&=�&=�>�?�1�D��&�&���0�0�<�<�>��
�
�
�
�T�%7�%7�
7�J����f�l�l�=
�
�I�I�;��"�"�.�.�/�
�
�M�M��M�M��.�.� $�}�}�8�8�D��
�"�!/�"��"���A��.�B�a�/�"���'�5�5��&�&�t�'>�'>�?�.2���
�;��1�$��*�*��T�4�4�@�@�B��� %�[�1�D���I�I�:�K�H��-�-� 
�-���%�%�c�*�$�2J�2J�J��C��)��9�9�D�$7�$7�7�
�"�"�3�'�-� 
����YE��(��v��: 
s�R�++R�5R
�%ARc��tj�x|_|_t	j
�|_t|�|_i}i}|jr�|jj�D]�\}}t|t�s|j||�}n|}d}t|tj�rE|jD]6}|j jj#|�s�)d}|||<||f||<�8|s��|j%||d����|j&r�|j&jj�D]�\}}|j)||dd��r�|j+|�}	|	r3|j-||d|	��}
|
||<|	jD]	}||
f||<��b||jvs�q|j/||d���|j0jD]�}||vr||\}}
|j%||
d���$||jvr�3|j2xsd|j4z}|j)|j4||j jj#|�|��r��|j7�D]*}||jvs�|j|j4}�,|j%||dd����y)NTF)r,r)�	warn_only�
incoming_prop��r,�	setparent)�sql_base�ColumnCollectionr�r�r!�OrderedDictr�r�r�r�r r�r+�_make_prop_from_columnr rRr|�contains_column�_configure_propertyrr!�get�%_reconcile_prop_with_incoming_columnsr"r�r�r$r)r��explicit_col_props_by_column�explicit_col_props_by_keyr$�prop_arg�possible_col_prop�_map_as_property_now�	given_col�inherited_proprt�new_prop�inc_colrr%�
column_keyr�s                rmr�zMapper._configure_properties�s�� (� 9� 9� ;�;���t�v��&�&�(���"0��!5���
�	%�EG�!�� � �!%�!6�!6�!<�!<�!>�
��X�!�(�N�;�(,�(C�(C��X�)�%�)1�%�(,�$��/��1J�1J�K�%6�%>�%>�	��+�+�-�-�=�=�i�H�38�0�=N�5�c�:� #� 1�G�8��C�	&?�(��,�,��)�"�-��3"?�D�=�=�'+�}�}�';�';�'A�'A�'C�#��^��'�'��S��d�'�K�� 9� =� =�c� B�
� �#�I�I��&�"'�&3�	 J� �H�6>�-�c�2�#0�#8�#8���$�A�4�W�=�$9�
����+��2�2�3���N�)(D�8�-�-�5�5�F��5�5�9��@�	��T��(�(��d��(�?���4�1�1�1���,�,�2��f�j�j�@�J��#�#��
�
���&�&�(�(�8�8��@��	$����.�.�0���V�5�5�5�!'�!9�!9�&�!A�!E�!E�J�1�
�$�$�����	
%�
�76rlc�*��d}d�|j��*d}t|jt�r	|j|j|_|j|jvr|j|j}�n�t|jt�rGt|jtj�stjd��|j}�n:|jj|j�}|��d}d}|j}t|tj�r^|j�.|jd�|jdj|�	�$tj d|j"z��d}t%|dd�}|r,|j'||d|�r<tj d	|z��|j)d
�x|_}|j*}tj||��}|j-|||d��|j.d
|_|j*�n�|j1�D]�}|j��|j|jur|j|_n*|jj|j�|_|j�5|j2|_|j4|_|j6|_yd|_d|_y|j8r!|j�tj d��|r �fd�}	�|_�fd�}
|	|_|
|_yd|_d|_y#t$r(}tjd|jz�|�d}~wwxYw)a�Configure an attribute on the mapper representing the
        'polymorphic_on' column, if applicable, and not
        already generated by _configure_properties (which is typical).

        Also create a setter function which will assign this
        attribute to the value of the 'polymorphic_identity'
        upon instance construction, also if applicable.  This
        routine will run when an instance is created.

        FNTzPCan't determine polymorphic_on value '%s' - no attribute is mapped to this name.zUOnly direct column-mapped property or SQL expression can be passed for polymorphic_onrzkCould not map polymorphic_on column '%s' to the mapped table - polymorphic loads will not function properlyr$z6Cannot exclude or override the discriminator column %r�_sa_polymorphic_on)�_instrumentrvrz�The Mapper.polymorphic_abstract parameter may only be used on a mapper hierarchy which includes the Mapper.polymorphic_on parameter at the base of the hierarchy.c�B��|j}|jjj}|�M|jjjr-tjd|jj�d���|j��j|||d�y)NzCan't instantiate class for z,; mapper is marked polymorphic_abstract=True)	r�rCr�r�r�r�r5�get_implrj)�state�dict_r��polymorphic_keys   �rmr�zGMapper._configure_polymorphic_setter.<locals>._set_polymorphic_identity�s�����
�
��
�M�M�(�(�=�=�%�)�0��
�
�,�,�A�A� �4�4�6�u�}�}�7K�7K�6L�ME�E���
����/�3�3���(��	rlc�|���|vr7|�|jvr%tjdt|�|�f�yyy)NznFlushing object %s with incompatible polymorphic identity %r; the object may not refresh and/or load correctly)�"_acceptable_polymorphic_identitiesr!�warn_limitedr')r�r�r�r�s   �rmr�zLMapper._configure_polymorphic_setter.<locals>._validate_polymorphic_identity�sW���#�u�,��o�.�!�D�D�E��%�%�G�#�5�)�5��+A�B�	�E�-rl)r�r�rr�rNr�r�r�r+r rRr�r^r4rAr�r5r�getattrr!�labelr$r}r�rr�r�r�r�)r�r,�setterrPr%rk�
instrumentr$r�r�r�r�s           @rmr�z$Mapper._configure_polymorphic_setter+s������)-�����*��F��$�-�-�s�3��*.�+�+�d�6I�6I�*J�D�'��"�"�d�&<�&<�<��-�-�d�.A�.A�B���D�/�/��@�"��'�'��)B�)B��!�.�.�;���
�*�*���-�-�B�B��'�'����;�#�F�!&�J��-�-�C�!�#�v�}�}�5��-�-�5��0�0��3�;��0�0��3�H�H��M�� �%�8�8�?�"�o�o�.���"&�J��c�5�$�/����+�+�C��e�S�A�$�8�8�6�8;�<���
14�	�	�:N�0O�O�D�'�#��'�'�C�!�0�0��*�M���(�(��d���(�N�#'�,�,�q�/�D��"�h�h�O��.�.�0���(�(�4��.�.�&�2K�2K�K�.4�.C�.C��+�!�3�3�.�.�v�/D�/D�E��+��*�*�6�"�<�<��6�#�8�8��2�#�A�A��;��:>��6�59��2��;1�>�$�$��)<�)<�)D��,�,�P��
��
�0*9�D�&�
�.G�D�*�.�
�/�*.�D�&�-1�D�*��] �� �.�.�/�15�1D�1D�E���	���s�M!�!	N�*#N
�
Nc�N�|j�|j|jSyrh)r�r�r�s rm�_version_id_propzMapper._version_id_prop�s(�����*��)�)�$�*=�*=�>�>�rlc��t�}t|g�}|ra|j�}|j|jur6|j	|j
�|j
|j�|r�a|Srh)rjr�popleftr�rfr��extendr�)r��
identities�stack�items    rmr�z)Mapper._acceptable_polymorphic_identities�sg���U�
��t�f�
����=�=�?�D��&�&�$�*A�*A�A����t�8�8�9����T�5�5�6�	��rlc�H�t|jj��Srh)�	frozensetr��valuesr�s rm�	_prop_setzMapper._prop_sets������+�+�-�.�.rlzsqlalchemy.orm.descriptor_propsc��tjj}|js|j	||dd��y||j
vrx|jj||�}||us2t|tj�r=|j|jur$|j	||j�|d��yyyy)NFrvT)r!�	preloaded�orm_descriptor_propsr�r}r�r��_get_class_attr_mror�r�InstrumentedAttribute�
_parententity�parent�ConcreteInheritedProperty)r�r$r%r,�descriptor_props�implementing_attributes      rmr"z Mapper._adapt_inherited_propertys����>�>�>�>���}�}��$�$�S�$�U�e�$�L�
����
#�&*�%7�%7�%K�%K��T�&�"�&��-��*�J�,L�,L��+�8�8�D�K�K�G��(�(��$�>�>�@��"�	)��H��$rl)r,rw�warn_for_existingc
�,�tjj}|jd||jj
�t
|t�s|j||�}n|}t
|tj��rT|jj|jd�}|��|jr�|g}	|jj�D]�}
|
j j|jd�}|�L|	D]}|jj#|��|jj|jd�}n|	j%|
���|�[|jd}t'|d�r�t'|d�r|j(|j*vr�|j,j/|�ngt'|d�r[|j(|j*vrC||j*|j(vr(|j*|j(j/|�t'|d�s0||j0uxs|jd|j0u|_t
|t4j6�r|x|_|_|jj/||�|jD]"}|j<D]}||j>|<��$tA|d|�|k7rWtjBd|jDj
�d	|j8�d
|�d|j8�d|j8�d	��||_|r|jG||�||jHvrTtA|jH|d
d�r:|jH|jJ}
tMjNd|
�d|�d|�d|
����||jHvr�t
|jH||jP�sxt
||jR�sb|r4tjTd|jDj
�d	|�d|�d�d�|jH|}|jVjY|d�n�|r�|jDjZj]|d��zt
||jR�sdt
|jHj]|d�|jP�s4tjTd|jDj
�d	|�d|�d�d�||jH|<|j^s|ja|�|jbD]}|je|||��|r!|jg�|ji|�|jjr|jm�|S)Nz_configure_property(%s, %s)rrjr�r��_is_polymorphic_discriminatorr$zORM mapped property r�z 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!r�r�r��	__class__r�r�r+�_property_from_columnr rRr�r^r�rrr|�_refresh_for_new_columnrr>r�r�rjrfr�r�r:�Labelr$�
_tq_key_labelrbr�r�rrz�
set_parentr�r�r�r�r�rN�warn_deprecatedr�rKrJr~ryr7r�r"r,�post_instrument_classr�r�)r�r$r�r,rwr�r�r%rk�path�m�m2�	proxy_col�syn�oldpropr�s                rmr}zMapper._configure_property(s��� �>�>�>�>���	�	�)�3��0B�0B�0K�0K�	
��(�N�3�(,�(B�(B��X�)�D��D��d�J�5�5�6��)�)�>�>�t�|�|�A��O�C�
�{�t�}�}��v�����6�6�8�A��-�-�<�<�T�\�\�!�_�M�C���"&�B��1�1�I�I�#�N�#'�"�5�5�J�J� �L�L��O�����K�K��N�9��{��l�l�1�o���4�!2�3���W�-��y�y��(;�(;�;��(�(�,�,�T�2��D�"2�3��	�	�T�%8�%8�8��4�#6�#6�s�y�y�#A�A��'�'��	�	�2�6�6�s�;�
�4�!@�A��4�.�.�.�>��|�|�A��$�*=�*=�=��2�
�#�z�/�/�0�/2�1���#�+��L�L���S�#�&��|�|��!$���I�8<�D�*�*�9�5�"/�$��4���$��+��I�I�&�t�{�{�';�';�&<�A�d�h�h�Z�H)��'��!�X�X�L�)����|�1�	&�
������O�O�D�$�'��$�+�+��'��K�K���2�E�#
��+�+�c�"�5�5�C��&�&�'*�3��S�:��
�
�4�;�;������C� �"2�"L�"L���t�%5�%E�%E�F� ��$�$�,�T�[�[�-A�-A�,B�!�C�5���f���
�
��k�k�#�&�G����#�#�G�T�2�
����$�$�(�(��d�3�?��t�%5�%E�%E�F��������T�*� �:�:��

� � �(����)=�)=�(>�a��u�D��&����
� ����C������!�!�$�'��.�.�F��,�,�S�$��=�/���I�I�K��&�&�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!r�r�r^r|r�r�r�rr rR)r�r$rr��
mapped_columnr��mcs       rmr{zMapper._make_prop_from_column�s����,�,�v�&���
��A��(�(�=�=�a�@�B��z��%�%�:�:�1�=���>�
�+�+�C�C�B�G��,�,�A�A�!�D���:� �.�.�
),�T�1�	6���
� � ��$�'�(�(�(�-�8�8rlc��|r(|jst|tj�s|S|jd}|r||jvr|S|�|�J�|}|jd|f}n$|�J�|jd}||jdf}|j
r||j
vrs|j
|�sb||jurT||jurFd|jd�d|�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)r�r�r rRr�r��shares_lineager�r!rr�r5�copy�insertr�)r�r$�
existing_proprsrt�
single_column�existing_column�incoming_column�equated_pair_key�msgr�s           rmrz,Mapper._reconcile_prop_with_incoming_columns�sn����M�M��m�Z�-F�-F�G� � �'�/�/��2���_�
�0E�0E�E� � �� � �,�,�,�+�O� -� 5� 5�a� 8�/�J�� �(�(�(�+�3�3�A�6�O� /��1F�1F�q�1I�J���0�0�$�D�,H�,H�H�#�2�2�?�C��t�':�':�:��t�':�':�:�"�)�)�"�-�#���
���	�	�#���0�0��5�5�
!�%�%�'��������?�3��	�	�
.��	
�
�rlc��tjj}|jj	|�}t|tj�r!|j||||j|u��S|�t||j�r|j||�Stjd|�d|�d|j�d|�d�	��)zrgenerate/update a :class:`.ColumnProperty` given a
        :class:`_schema.Column` or other SQL expression object.)r�rsz$WARNING: when configuring property 'r�r�z' 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!r�r�r�r~r�r rRrr�r�r{r�r�r$)r�r$rr�r%s     rmr�zMapper._property_from_column4	s��� �>�>�>�>���{�{���s�#���d�J�5�5�6��=�=���$��+�+�T�1�	>��
��\�Z��"�<�<�
��.�.�s�F�;�;��&�&�*-�d�F�J�J��F�
�

rlz�This warning originated from the `configure_mappers()` process, which was invoked automatically in response to a user-initiated operation.c�b�|jjrt|jhd��yy)NT��cascade)rK�_new_mappers�_configure_registriesr�s rm�_check_configurezMapper._check_configureY	s&���=�=�%�%�!�4�=�=�/�4�@�&rlc��|jd�|jj�D��cgc]	\}}||f��}}}|D]_\}}|jd|�|j|ur|js|j�|js�O|j|��a|jd�d|_ycc}}w)z�Call 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)	r�r�r r��_configure_startedr,�_configure_finishedr�r�)r�r$r%�ls    rm�_post_configure_propertiesz!Mapper._post_configure_propertiesc	s���	
�	�	�8�9�*.�+�+�*;�*;�*=�>�*=�Y�S�$�c�4�[�*=��>��I�C���I�I�*�C�0��{�{�d�"�4�+B�+B��	�	���'�'��*�*�4�0��	
�	�	�9�:�����
?s�B=c�X�|j�D]\}}|j||��y)z^Add the given dictionary of properties to this mapper,
        using `add_property`.

        N)r �add_property)r��dict_of_propertiesr$�values    rm�add_propertieszMapper.add_propertiesz	s+��
-�2�2�4�J�C�����c�5�)�5rlc��|j|||jd��}t|t�sJ�||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,r�N)r}r�r�r+r�)r�r$r%s   rmr�zMapper.add_property�	sH���'�'���D�O�O�t�(�
���$��/�/�/�%)����c�"rlc�N�|j�D]}|j��yrh)r�_reset_memoizations�r�r�s  rmr�zMapper._expire_memoizations�	s!���*�*�,�F��&�&�(�-rlc���d|jjzdz|jduxr|jjxst	|j�z|j
xrdxsdzdzS)N�(�|z|non-primaryru�))rzr�r|rrryr�s rm�	_log_desczMapper._log_desc�	s���
��k�k�"�"�
#��
�� � ��,�1��$�$�0�0�)��t�'�'�(�

����2�N�8�b�
:��	
�	
rlc�`�|jjd|zg|jf|z���y�Nz%s )�logger�infor��r�r��argss   rmr�zMapper._log�	s+�����������B����(9�D�(@�Brlc�`�|jjd|zg|jf|z���yr�)r��debugr�r�s   rm�
_log_debugzMapper._log_debug�	s+��������%�#�+�C�$�.�.�):�T�)A�Crlc�J�dt|�|jjfzS)Nz<Mapper at 0x%x; %s>)�idrzr�r�s rm�__repr__zMapper.__repr__�	s ��%��D��4�;�;�3G�3G�(H�H�Hrlc���d|jj�|jxrdxsd�d|j�|jj�d�S|j
j�d�S)Nr�z (non-primary)rur�z)])rzr�ryr|rr�r�s rm�__str__zMapper.__str__�	st���K�K� � ����1�!1�7�R�7��#�#�/�� � �,�,�9�	
�	
��,�,�8�8�9�	
�	
rlc�"�d}|j�D]l}|jD][\}}d}tj|�j	|||j
��}|jr|ry|jr�W|r�Zy�n|jr|Sy)NFT)�
optimistic)rr�r�manager_of_class�
has_parent�has_identityr�)r�r��orphan_possibler�r$�clsr�s       rm�
_is_orphanzMapper._is_orphan�	s������*�*�,�F�"�2�2���S�"&��'�8�8��=�H�H��3�5�+=�+=�I��
��(�(�Z� ��.�.�z��3�-�� � �"�"�rlc��||jvSrh)r�)r�r$s  rm�has_propertyzMapper.has_property�	s���d�k�k�!�!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)r�r�rNr�r5)r�r$�_configure_mappersrPs    rm�get_propertyzMapper.get_property�	sg��
��!�!�#�	��;�;�s�#�#���	��,�,��4�&� 3�C�5�98�8���	
��	�s�#�	A�A	�	Ac� �|j|S)zkGiven a :class:`_schema.Column` object, return the
        :class:`.MapperProperty` which maps this column.)r�)r�rs  rm�get_property_by_columnzMapper.get_property_by_column�	s���%�%�f�-�-rlc�H�t|jj��S)z1return an iterator of all MapperProperty objects.)�iterr�r�r�s rm�iterate_propertieszMapper.iterate_properties�	s���D�K�K�&�&�(�)�)rlc�0�|dk(rt|j�}n�|r�t�}tj|�D]k}t|�}|j
|�stj|�d|����|� |j|j���[|j|��m|jD�cgc]	}||vs�|��}}ng}|�>ttj|d���}|D�cgc]}|j|vs�|��}}|Scc}wcc}w)z�given 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!r�r#�isar�r5rrrfrr`r|)r��spec�
selectable�mappers�
mapper_setr�r�s       rm�_mappers_from_speczMapper._mappers_from_spec�	s���3�;��4�4�4�5�G�
���J��\�\�$�'��$�Q�'���u�u�T�{� �4�4�9:�D�A����%��%�%�a�&7�&7�&9�:��N�N�1�%�(�#'�";�";�O�";�Q�q�J��q�";�G�O��G��!���$�$�Z��F��F�#*�E�'�Q�Q�]�]�f�-D�q�'�G�E����P��Fs�9	D�D�2D�Dc�0�|j}|D]�}||ur�|jrtjd��|jr�6|r'|j|j|j�}�_|j|j|j�}��|S)z�given 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.)	r�r�r�r5r�rr|r��	outerjoin)r�r�	innerjoin�from_objr�s     rm�_selectable_from_mapperszMapper._selectable_from_mappers
s����*�*���A��D�y���z�z��0�0�A����X�X��'�}�}��
�
�q�':�':� �H� (�1�1��
�
�q�':�':� �H��$�rlc���|j}|�yt|t�sy|jduxs@|jduxr0|jj
xr|jjS�NFT)r�r�rA�server_default�default�	is_scalar�is_callable)r��vid_cols  rm�!_version_id_has_server_side_valuez(Mapper._version_id_has_server_side_value1
sp���%�%���?���G�V�,���)�)��5�����t�+�����1�1�1�8�#�O�O�7�7�7�	
rlc��|jrs|jrg|j�[|jj||d��j	|j
D�cgc]}|js|j��c}�Sycc}w)N)�parententity�parentmapper)r�rr��	_annotate�in_rr�r��r�r�s  rm�_single_table_criterionzMapper._single_table_criterionC
s����;�;�4�=�=�T�-@�-@�-L��&�&�0�0�!%�t�<���c�"�6�6��6���1�1��*�*�6���
���s�Bc�l�|jxr't|jdtj�S)z�return 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)r�r�r:�AliasedReturnsRowsr�s 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*r�r�r�s rm� _should_select_with_poly_adapterz'Mapper._should_select_with_poly_adapter`
sK��V
�4�4�
7��*�*�
7�� � �D�D�
7����6�6�		
rlc�p�|j�|jsgS|j|j�Srh)r�r�rr�s rm�_with_polymorphic_mappersz Mapper._with_polymorphic_mappers�
s5�������$�$��I�&�t�&�&��(=�(=�>�>rlc�$�|j�y)z�This 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)r�r�s rm�
_post_inspectzMapper._post_inspect�
s��	
���rlc��|js|jS|j\}}|�|S|j|j||�d�S�NF)r�r�rr)r�rrs   rm�_with_polymorphic_selectablez#Mapper._with_polymorphic_selectable�
sX���$�$��*�*�*��0�0���j��!����0�0��'�'��j�9�5��
rlc	��|jj�D��cic]\}}|td�|D����c}}Scc}}w)Nc3�NK�|]}|jjs�|���y�wrh)r��should_evaluate_none�rVrks  rmrXz6Mapper._insert_cols_evaluating_none.<locals>.<genexpr>�
s �����&��#�(�(�*G�*G��w�s�%�%�r�r r��r�r�r�s   rm�_insert_cols_evaluating_nonez#Mapper._insert_cols_evaluating_none�
sY��#'�"5�"5�";�";�"=�	
�#>���w�
�9��&���
�#>�	
�	
��
��?c	��|jj�D��cic]\}}|td�|D����c}}Scc}}w)Nc3�K�|]J}|js<|js0|js$|jjs|j
���Ly�wrh)r}rrr�r6r$r7s  rmrXz.Mapper._insert_cols_as_none.<locals>.<genexpr>�
s@�����"�C�����*�*�������5�5����"�s�AAr8r9s   rm�_insert_cols_as_nonezMapper._insert_cols_as_none�
sY��#'�"5�"5�";�";�"=�

�#>���w�
�9��"���
�#>�

�
	
��

r;c���|jj�D���cic].\}}||D�cic]}|j|j|��c}��0c}}}Scc}wcc}}}wrh)r�r r�r$�r�r�r�rks    rm�_propkey_to_colzMapper._propkey_to_col�
si��#'�"5�"5�";�";�"=�
�"=���w�
�G�L�G�S�D�*�*�3�/�3�3�S�8�G�L�L�"=�
�	
��L��
s�
A�!A�
A�Ac��|jj�D���cic])\}}|t|D�cgc]}|j��c}���+c}}}Scc}wcc}}}wrh)r�r r�r$�r�r��pksrks    rm�_pk_keys_by_tablezMapper._pk_keys_by_table�
s\��#�0�0�6�6�8�
�8�
��s�
�9��5��#�c�g�g��5�6�6�8�
�	
��5��
s�A�A�	A�Ac
���|jj�D���cic]6\}}|t|D�cgc]}|j|j��c}���8c}}}Scc}wcc}}}wrh)r�r r�r�r$rCs    rm�_pk_attr_keys_by_tablezMapper._pk_attr_keys_by_table�
si��#�0�0�6�6�8�
�8�
��s�
�9��M��#�d�4�4�S�9�=�=��M�N�N�8�
�	
��M��
s�A$� A�	A$�A$c��|jj�D���cic]W\}}|ttd|�D�cgc]2}|j�"|j
�|j
jr|��4c}���Yc}}}Scc}wcc}}}w�NzIterable[Column[Any]])r�r r�r	rr�is_clause_elementr@s    rm�_server_default_colszMapper._server_default_cols�
s��� #'�"5�"5�";�";�"=�

�#>���w�
�9� $�$;�W�E��E���)�)�5����/��K�K�9�9��E��
�

�#>�

�
	
����

��B�7B�2	B�Bc��|jj�D���cic]W\}}|ttd|�D�cgc]2}|j�"|j
�|j
jr|��4c}���Yc}}}Scc}wcc}}}wrI)r�r r�r	�server_onupdate�onupdaterJr@s    rm�_server_onupdate_default_colsz$Mapper._server_onupdate_default_cols�
s��� #'�"5�"5�";�";�"=�

�#>���w�
�9� $�$;�W�E��E���*�*�6����0��L�L�:�:��E��
�

�#>�

�
	
����

rLc	��|jj�D��cic]\}}|td�|D����c}}Scc}}w)Nc3�NK�|]}|j��|j���y�wrh�r$r7s  rmrXz2Mapper._server_default_col_keys.<locals>.<genexpr>�����L������8K�S�W�W����%�%)rKr r��r�r��colss   rmr�zMapper._server_default_col_keyssL�� $�8�8�>�>�@�
�@���t�
�9�L��L�L�L�@�
�	
��
r;c	��|jj�D��cic]\}}|td�|D����c}}Scc}}w)Nc3�NK�|]}|j��|j���y�wrhrSr7s  rmrXz;Mapper._server_onupdate_default_col_keys.<locals>.<genexpr>rTrU)rPr r�rVs   rm�!_server_onupdate_default_col_keysz(Mapper._server_onupdate_default_col_keyssL�� $�A�A�G�G�I�
�I���t�
�9�L��L�L�L�I�
�	
��
r;c�`��t�}|j�|jj�D].\}}|j	�fd�|j��D���0|jj�D].\}}|j	�fd�|j��D���0|S)Nc3�<�K�|]}�|j���y�wrhrS�rVrk�col_to_propertys  �rmrXz@Mapper._server_default_plus_onupdate_propkeys.<locals>.<genexpr>!�$������@�C� ��$�(�(�@���c3�<�K�|]}�|j���y�wrhrSr]s  �rmrXz@Mapper._server_default_plus_onupdate_propkeys.<locals>.<genexpr>&r_r`)rjr�rKr rrerP)r��resultr�r�r^s    @rm�&_server_default_plus_onupdate_propkeysz-Mapper._server_default_plus_onupdate_propkeyss�����5���0�0��"�7�7�=�=�?�N�E�7��M�M��"�/�/��@��
�@�
#�@�@�F�F�H�N�E�7��M�M��"�/�/��@��
�I�
�
rlc��|||d�}|j|jur4|jj|||d��jd|d��|d<|jj|�jd|d��S)N)�entity_namespacer"r#�orm��compile_state_plugin�plugin_subject�	dml_table)r�r|r$�_set_propagate_attrsr)r�rs  rm�__clause_element__zMapper.__clause_element__,s���!%� � �'
��
�"�"�$�*:�*:�:�(,�'7�'7�'A�'A�(,�$(�$(��(�#�"�).�$�G��

��$����(�(��5�J�J�%*�d�C�
�	
rlc�v�tj�j|||dd��jd|d��S)NT)rer"r#�identity_tokenrfrg)r:�nullr$rkr�s rm�select_identity_tokenzMapper.select_identity_tokenDsC��
�O�O��
�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.

        )r3r�s rmrzMapper.selectableUs���0�0�0rlc��|dvr&tjtj|d��}|jr%|s|jd}|dur|jd}n|durd}|j||�}|�||fS||j
||�fS)Nr2TrrFr)r9r�r<r�r�rr)r�rrrrs     rm�_with_polymorphic_argszMapper._with_polymorphic_argsas����]�*�"�)�)��*�*�J�T��J�� � ���,�,�Q�/���U�"�!�2�2�1�5�
�
�5�
 ��J��)�)�$�
�;���!��J�&�&��D�9�9�'�9�M�M�Mrlc�J�t|j|j��Srh)r�_iterate_polymorphic_propertiesr.r�s rm�_polymorphic_propertieszMapper._polymorphic_propertiesys&����0�0��.�.�
�
�	
rlc���|j}|j}|D��cgc]L}t|tj�r0|j
r$|jD]}|r|j|n|���Nc}}Scc}}wrh)rv�_polymorphic_adapterr�r rR�_renders_in_subqueriesr�)r��poly_properties�adapterr%r�s     rm�_all_column_expressionszMapper._all_column_expressions�s{���6�6���+�+��(�
�'���$�
� 9� 9�:��+�+��\�\��	#*�G�O�O�A��q�0�"�	
1�'�
�	
��
s�AA3c���|r|j|�}n|j}|D�cgc]7}t|tj�r|j
|jdf��9c}Scc}w)Nr)rurvr�r rRr$r�)r��polymorphic_mappersrzr%s    rm�_columns_plus_keyszMapper._columns_plus_keys�sm���"�B�B�#��O�#�:�:�O�(�
�'���$�
� 9� 9�:��X�X�t�|�|�A��'�'�
�	
��
s�<A$c��|jrFtjtjj||j
|jd��Sy)NF)r�equivalents�limit_on_entity)r*�orm_utilrU�_TraceAdaptRole�MAPPER_POLYMORPHIC_ADAPTERr�_equivalent_columnsr�s rmrxzMapper._polymorphic_adapter�sH���3�3��&�&��(�(�C�C���?�?� �4�4� %��
�rlc
#�^K�|�|j}|s|jD]}|���ytjt	|g|zD�cgc]}t|j���c}��D];}t
|dd�r(|j�|jd|jur�8|���=ycc}w�w)zUReturn an iterator of MapperProperty objects which will render into
        a SELECT.Nr�Fr)	r.rr!�unique_listrrr�r�r�)r�rr�r�s    rmruz&Mapper._iterate_polymorphic_properties�s������?��4�4�G���,�,����-��%�%��(,�f�w�&6��&6�F��V�6�6�7�&6������1�=�u�E��'�'�/��y�y��|�4�+>�+>�>�������s�AB-�B(�!AB-c�`�|j�tj|j�S)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`

        )r�r!�ReadOnlyPropertiesr�r�s rm�attrszMapper.attrs�s&��F	
�����&�&�t�{�{�3�3rlc�n�tjt|jj	���S)ayA 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!r�r�r��_all_sqla_attributesr�s rm�all_orm_descriptorszMapper.all_orm_descriptors�s/��D�&�&���#�#�8�8�:�;�
�	
rlc�^�tjj}|jD�chc]}|j��}}|j
j
�D��cic]@\}}t||j�r%|j|vr|j|j��Bc}}Scc}wcc}}w)z~return a dictionary of {syn_attribute_name: pk_attr_name} for
        all synonyms that refer to primary key columns

        )
r!r�r�rir$r�r r�rNrF)r�r�r%�pk_keysrpr�s      rm�_pk_synonymszMapper._pk_synonyms1s��� �>�>�>�>��(,�(@�(@�A�(@��4�8�8�(@��A��+�+�+�+�-�
�-���3��#�/�?�?�@����G�#�
�G�G�S�X�X��-�
�	
��B��
s�B$�AB)c�l�tjj}|j|j�S)z�Return 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!r�r��_filter_propertiesrN)r�r�s  rm�synonymszMapper.synonymsCs,�� �>�>�>�>���&�&�'7�'G�'G�H�Hrlc��|jSrhr�r�s rmrezMapper.entity_namespaceTs���{�{�rlc�@�|jtj�S)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.

        )r�r rRr�s rm�column_attrszMapper.column_attrsXs���&�&�z�'@�'@�A�Arlzsqlalchemy.orm.relationshipsc�h�|jtjjj�S)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.

        )r�r!r��orm_relationshipsrSr�s rm�
relationshipszMapper.relationshipsfs*��6�&�&��N�N�,�,�A�A�
�	
rlc�h�|jtjjj�S)z�Return a namespace of all :class:`.Composite`
        properties maintained by this :class:`_orm.Mapper`.

        .. seealso::

            :attr:`_orm.Mapper.attrs` - namespace of all
            :class:`.MapperProperty`
            objects.

        )r�r!r�r�rMr�s rm�
compositeszMapper.composites�s*���&�&��N�N�/�/�A�A�
�	
rlc���|j�tjtj�fd�|jj�D���S)Nc3�F�K�|]\}}t|��s�||f���y�wrh)r�)rVrp�v�type_s   �rmrXz,Mapper._filter_properties.<locals>.<genexpr>�s'������#6�4�1�a�*�Q��:N��A��#6�s�!�	!)r�r!r�rzr�r )r�r�s `rmr�zMapper._filter_properties�sL���	
�����&�&�����#'�;�;�#4�#4�#6��
�
�	
rlc	�,�t|jd�D��cgc]+\}}|tjd|z|j��f��-}}}tj
|D��cgc]
\}}||k(��c}}�t
j|�fScc}}wcc}}w)z�create 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_%d�r�)�	enumerater}r5�	bindparamr��and_r!�column_dict)r��idxr}�paramsrpr�s      rm�_get_clausezMapper._get_clause�s���%.�d�.>�.>��$B�
�
%C� ��[���
�
�g��m�;�3C�3C�D�
�%C�	�
�
�H�H�F�3�F�&�1�a�q�A�v�F�3�4����V�$�
�	
��
��4s�0B
�!B
c���i��fd�}|jjD]2}|j��tj|jid|i��4�S)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�|j�vr)�|jj	|j
�n|j
h�|j<|j
�vr)�|j
j	|j�y|jh�|j
<yyrh)�operatorr;�eq�leftrf�right)�binaryrbs �rm�visit_binaryz0Mapper._equivalent_columns.<locals>.visit_binary�s�������)�,�,�.��;�;�&�(��6�;�;�'�+�+�F�L�L�9�+1�<�<�.�F�6�;�;�'��<�<�6�)��6�<�<�(�,�,�V�[�[�9�,2�K�K�=�F�6�<�<�(�/rlr�)r�rr�r>�traverse)r�r�r�rbs   @rmr�zMapper._equivalent_columns�sZ��� (*��		9��&�&�;�;�F��'�'�3��!�!��,�,�b�8�\�2J��<��
rlc�~�t|ttjtj
f�ry||jvSr2)r�r(rrPr:r\�_dataclass_fields)r��
assigned_name�objs   rm�_is_userland_descriptorzMapper._is_userland_descriptor�s=���� ��,�,��(�(�
�
�� ��(>�(>�>�>rlc�z�tj|j�D�cgc]}|j��c}Scc}wrh)r!�dataclass_fieldsrzrF)r��fs  rmr�zMapper._dataclass_fields�s/�� $� 5� 5�d�k�k� B�C� B�1���� B�C�C��Cs�8c�8�|�tj|�ry|rQ|jjj	|d�	�[|j||jj|�r2y|jj|d�}|�|j||�ry|j�3||jvr%|�||jvr|jd|z�y|j�3||jvs|�#||jvr|jd|z�yy)z�determine 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~r�r�r�r�r�r�)r�rFr�rr�attrs      rmr!zMapper._should_exclude�s(����(�"?�"?��"G��
��{�{�#�#�'�'��t����"�:�:��t�{�{�3�3�M�B����%�%�9�9�-��N�D���D�$@�$@��t�%��
�#�#�/��D�3�3�3���6��1H�1H�#H��I�I�1�T�:�;���"�"�.��D�+�+�+��"�v��1H�1H�'H��I�I�-��6�7��rlc�2�|j|juS)zXReturn true if the given mapper shares a
        common inherited parent as this mapper.)r��r��others  rm�
common_parentzMapper.common_parent
s�����5�#4�#4�4�4rlc��|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

        )r�rr�s  rm�
is_siblingzMapper.is_sibling
sC��
���� 1� 1�1�
$��H�H�U�O�#�
$��I�I�d�O�#�	
rlc��|j�}|j�|rt|�j|�St|�|uSrh)�primary_mapperr�r%r)r�r��allow_subtypes�ss    rm�_canloadzMapper._canload(
sF��
���!�����*�n� ��'�+�+�A�.�.� ��'�1�,�,rlc�N�|}|r||ur|j}|r||ur�t|�S)z>Return True if the this mapper inherits from the given mapper.)rr~)r�r�r�s   rmrz
Mapper.isa1
s/��$(���A�U�N��
�
�A��A�U�N��A�w�rlc#�<K�|}|r|��|j}|r�yy�wrh)rr&s  rmrzMapper.iterate_to_root9
s!����#'����G��
�
�A��s��c���g}t|g�}|r?|j�}|j|�|j|j�|r�?tj|�S)z�The collection including this mapper and all descendant mappers.

        This includes not just the immediately inheriting mappers but
        all their inheriting mappers as well.

        )rr�rr�r�r!r�)r��descendantsr�r�s    rmrzMapper.self_and_descendants?
sZ�����t�f�
����=�=�?�D����t�$��L�L��1�1�2��� � ��-�-rlc�,�t|j�S)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
rr�s rm�polymorphic_iteratorzMapper.polymorphic_iteratorO
s���D�-�-�.�.rlc�.�|jjS)zSReturn the primary mapper corresponding to this mapper's class key
        (class).)r�r�r�s rmr�zMapper.primary_mapper\
s���!�!�(�(�(rlc�B�|jjjSrh)r�r�r�r�s rm�primary_base_mapperzMapper.primary_base_mapperb
s���!�!�(�(�4�4�4rlc��|j}|r|D�cgc]}|j|��}}|j�}|D]}||vs�yycc}wr)r}r��keys)r�rbr{rmr��rkrks       rm�_result_has_identity_keyzMapper._result_has_identity_keyf
sV��/3�/?�/?���3:�;�7�a�w���q�)�7�G�;�
�[�[�]���C��"�}�����
<s�A	c����|j}|r|D�cgc]}|j|��}}t|d�r
|j�n|�|jt�fd�|D��|fScc}w)a�Return 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�|]	}�|���y�wrhrk)rVr�mappings  �rmrXz/Mapper.identity_key_from_row.<locals>.<genexpr>�
s�����8��f�'�&�/��s�)r}r�r>r�r�r)r��rowrnr{rmr�r�s      @rm�identity_key_from_rowzMapper.identity_key_from_rowq
su���"04�/?�/?���3:�;�7�a�w���q�)�7�G�;��3�
�#��l�l�G��G�
� � ��8��8�8��
�	
��<s�A(c�2�|jt|�|fS)z�Return 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.

        )r�r)r�r}rns   rm�identity_key_from_primary_keyz$Mapper.identity_key_from_primary_key�
s"��
� � ��+���
�	
rlc�l�tj|�}|j|tj�S)a�Return 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`.

        �r�instance_state�_identity_key_from_stater&�PASSIVE_OFF)r��instancer�s   rm�identity_key_from_instancez!Mapper.identity_key_from_instance�
s-���)�)�(�3���,�,�U�K�4K�4K�L�Lrlc��|j}|j}|jt|jD�cgc],}||j
jj|||���.c}�|jfScc}wrh)	r�rCr�rrir$�implr~rn)r�r��passiver�rCr%s      rmr�zMapper._identity_key_from_state�
s���
�
�
���-�-��� � ��!%� 8� 8�� 8���D�H�H�%�*�*�.�.�u�e�W�E� 8��
�
� � �	
�		
��s�1A;
c�v�tj|�}|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�)r�r�r��identity_keys    rm�primary_key_from_instancez Mapper.primary_key_from_instance�
s;���)�)�(�3���4�4��;�*�*�
���A��rlc���|jD�cgc]}|jj��c}�t��j	dg�r�fd�}|Sd�}|Scc}w)Nc�V��td�t�|jd�D��S)Nc3�:K�|]\}}|�||�n|���y�wrhrk)rV�key_fn�vals   rmrXz=Mapper._persistent_sortkey_fn.<locals>.key.<locals>.<genexpr>�
s*�����'A����$*�#5�F�3�K�3�>�'A�s�r)r�zipr$)r��key_fnss �rmr$z*Mapper._persistent_sortkey_fn.<locals>.key�
s,�����'*�7�E�I�I�a�L�'A���rlc� �|jdS�NrrS)r�s rmr$z*Mapper._persistent_sortkey_fn.<locals>.key�
s���y�y��|�#rl)r}r��sort_key_functionrj�
difference)r�rkr$r�s   @rm�_persistent_sortkey_fnzMapper._persistent_sortkey_fn�
s[���9=�9I�9I�J�9I�#�3�8�8�-�-�9I�J���w�<�"�"�D�6�*�
��
�
$��
��Ks�Ac�Z�|jD�cgc]}|j|��c}Scc}wrh)r}r��r�rks  rmrizMapper._identity_key_props�
s-��7;�7G�7G�H�7G���&�&�s�+�7G�H�H��Hs�(c�x�t�}|jD] }|j|j|��"|Srh)rjr�rr�)r��
collectionr�s   rm�_all_pk_colszMapper._all_pk_cols�
s6��-0�U�
��[�[�E����d�0�0��7�8�!��rlc�~�t|j�}|j�|j|j�|Srh)rjr}r�rf)r�rWs  rm�_should_undefer_in_wildcardz"Mapper._should_undefer_in_wildcard�
s5��(+�D�,<�,<�(=�����*��H�H�T�(�(�)��rlc�n�|jD�chc]}|j|j��c}Scc}wrh)r�r�r$r�s  rm�_primary_key_propkeyszMapper._primary_key_propkeys�
s3��;?�;L�;L�M�;L�C��&�&�s�+�/�/�;L�M�M��Ms� 2c��|j|}|j|jjj	|||��S�N�r�)r�rCr$r�r~�r�r�r�rr�r%s      rm�_get_state_attr_by_columnz Mapper._get_state_attr_by_column�
s?���%�%�f�-���}�}�T�X�X�&�+�+�/�/��u�g�/�N�Nrlc��|j|}|j|jjj	|||�yrh)r�rCr$r��set_committed_value�r�r�r�rr�r%s      rm�#_set_committed_state_attr_by_columnz*Mapper._set_committed_state_attr_by_columns7���%�%�f�-��
�
�
�d�h�h��$�$�8�8���u�Mrlc��|j|}|j|jjj	|||d�yrh)r�rCr$r�rjrs      rm�_set_state_attr_by_columnz Mapper._set_state_attr_by_columns9���%�%�f�-��
�
�
�d�h�h��$�$�(�(���u�d�Crlc��tj|�}tj|�}|j|||tj
��Sr)rr��
instance_dict�#_get_committed_state_attr_by_columnr&r�)r�r�rr�r�s     rm�_get_committed_attr_by_columnz$Mapper._get_committed_attr_by_columnsI���)�)�#�.���(�(��-���7�7��5�&�+�*A�*A�8�
�	
rlc��|j|}|j|jjj	|||��Sr)r�rCr$r��get_committed_valuers      rmr
z*Mapper._get_committed_state_attr_by_columnsG���%�%�f�-���}�}�T�X�X�&�+�+�?�?��5�'�@�
�	
rlc
�X�����j}t|�j�jjj��}tt
|D��cgc]-}||jD]}tj|d�����/c}}����jj�vry���fd�}g}d}	tt�j���D]�}
|
j�vrd}	n&t|
jt j"�sy|	s�=|
j$r�J|
j&sJ�|
j(rJ�|
j*�J�|j-|
j*��j/|
j���	t1j2|did|i�}||d<t7j8|�}g}
|D] }|
j;||j��"t7j<|
�j?|�jAtB�Scc}}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_columnsNc�d��|j}|j}|�|�y|j�vr{�j��j|t
j��}|tjvr
t��tjd||jj��|_y|j�vr{�j��j|t
j��}|tjvr
t��tjd||jj��|_yy)Nrr�)
r�r�r�r
r�r&�PASSIVE_NO_INITIALIZEr��	_none_set�_OptGetColumnsNotAvailabler5r�r�)r��leftcol�rightcol�leftval�rightvalr�r�r�s     ���rmr�z5Mapper._optimized_get_statement.<locals>.visit_binary;s
����k�k�G��|�|�H���(�"2���}�}�F�*��B�B���J�J��'�=�=�	C����h�0�0�0�4�6�6�!�m�m��'����):�):�������v�-��C�C���J�J��'�=�=�	D����x�1�1�1�4�6�6�"�}�}��(�&�,�,�*;�*;� ���.rlFrr�)"r�rjrer�r�r�rr�rr`r�r|�reversedrrr�r:r=r�rr�r�rrfr>�cloned_traverserr5r�r��select�where�set_label_stylerC)r�r��attribute_names�props�col_attribute_namesr$r�r��allconds�startr��
_traversed�condrWr�s``            @rm�_optimized_get_statementzMapper._optimized_get_statements�������!�/�2�?�?��L�L�%�%�*�*�,�
��#&�� 3��2��"�3�Z�/�/���(�(��$�?�/�@�2��
�#
�����'�'�6�1��	�>/1����
�t�D�$8�$8�$:�;�<�F��!�!�V�+����� 2� 2�J�4J�4J�K���V�]�]����&��!�?�?�*�*��/�/�;�;�;����� 8� 8�9��
�
�6�-�-�.�=� 	%�!�1�1����R�(�L�!9��J�%�H�Q�K��x�x��"����&�C��K�K��c�
�*�*�+�'�
�J�J���
�U�4�[�
�_�;�
<�	
��_��J*�	��	�s�2H�	H�	H)�(H)c#�K�|j|�r8|}|j�D]"}|��||ur||jvry|}||us�"yyy�wrh)rrr.)r�r��prevr�s    rm�_iterate_to_target_viawpolyz"Mapper._iterate_to_target_viawpoly�sZ�����8�8�F���D��)�)�+�����D�=�T��1L�1L�%L������;��,��s�AA
�A
c��iSrhrkr�s rm�&_would_selectinload_combinations_cachez-Mapper._would_selectinload_combinations_cache�s���	rlc���|j}	||S#t$rYnwxYw|j|�sJ�|}|j|�D]}|jdk(s�||u}nd}|||<|S)a�return 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.

        r�F)r,rNrr*r�)r��super_mapper�cacher�r��retvals      rm�+_would_selectin_load_only_from_given_mapperz2Mapper._would_selectin_load_only_from_given_mapper�s���@�;�;��	���&�&���	��	���x�x��%�%�%����1�1�&�9�A��!�!�Z�/��l�*���:�
�F�$��l���
s��	�c�x�|s,|}|j|�D]}|jdk(s�|cSyt|�}|D�cic]}|j|��}}|j	|g�D]M}|j}|j|�D]+}|jdk(s||vs�|j||�ccS�Oycc}w)Nr�)r*r�rjr�rBr~)r��enabled_via_opt�polymorphic_fromr�r��e�enabled_via_opt_mappersr�s        rm�_should_selectin_loadzMapper._should_selectin_load�s����%�F��5�5�f�=���%�%��3��H�>� �"�/�2�O�<K�&L�O�q�q�x�x��{�O�#�&L�)�/�/�1A�0B�C�������9�9�&�A�A��*�*�j�8�� 7�7�6�:�:�1�a�@�@�B�D���'Ms�B7zsqlalchemy.orm.strategy_optionsc	���tjj}|jsJ�|j�3|j
|j}t
|g|jz�}nt
|j�}|j|�}|j|�}|h}|j}	|	�F|	|urB|	jdk(r3|j|	�|	j}	|	�|	|ur|	jdk(r�3|j|jzD]�}
|
j|jvr�|
j|vs|
|vrXt!|
t"�s�?|j%t'|j(|
j�ft+|
j,�d��}��|j%t'|j(|
j�fddid��}��|j.D�cgc]}t1j2|ddi���}}t5|�dkDrt7j8|�}
n|d}
|j:r�|j<|usJ�t7j>|�jAtB�}|jDjG|
�}
|D�cgc]}|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.

        r�T)�_reconcile_to_other�
do_nothingF�
_orm_adaptrr�primary_keys)�	expanding)(r!r��orm_strategy_optionsrr�r�rjri�Loadr�rfr�r�r$r�r�r�r.�_set_generic_strategyr�rer��strategy_keyr}r�_deep_annotatergr5�tuple_�is_aliased_classr�rrrC�_adapterr�rr%r��order_by)r�r�r4�strategy_options�polymorphic_prop�
keep_props�disable_opt�
enable_opt�classes_to_includer�r%�pkr}�in_expr�qrps                rm�_subclass_load_via_inzMapper._subclass_load_via_in�s5�� �>�>�>�>���}�}��}����*�#�5�5�d�6I�6I�J���.�/�$�2J�2J�J�K�J��T�5�5�6�J�&�+�+�F�3��%�*�*�6�2�
�"�V��#'�=�=��
�M��)�)��"�"�j�0��"�"�1�%��
�
�A�
�M��)�)��"�"�j�0�
�%�%��(:�(:�:�D��x�x�t�1�1�1���{�{�0�0�D�J�4F�"�$�(;�<��'�=�=��V�4�4�d�h�h�?�A���*�*�+�(,�
>��
�*�?�?��V�4�4�d�h�h�?�A�!�4�(�(-�
@���3;�H�&�&�
�&��
�#�#�B��t�(<�=�&�	�
��{��a���j�j�+�.�G�!�!�n�G��"�"��=�=�D�(�(�(��
�
�6�"�2�2�.��A��o�o�.�.�w�7�G�@K�L��1�6�?�?�3�3�A�6��K�L��������C�M�M�.�D�I�J���h��%�A��
�
�4� �0�0�.��A��������C�M�M�.�D�I�J���h��%�A��*�k�)�)��A
��(Ms�M�"Mc�:�|j||j�Srh)rPr�r�s rm�_subclass_load_via_in_mapperz#Mapper._subclass_load_via_in_mapperFs���)�)�$��0@�0@�A�Arlc	#��K�t�}t�t�}}|jj|�sJ�t	t	|jj
j
��|||jfg�}|r�|d\}}	}
}|s|j��|	|uri|j�}|jr||jvr�N|
�J�|�J�t	|j||
|||��}
|
rm|j|
|ddf�nW|	|urS|j�\}}}}||||f��|jt	|j
j
��|||f�|r��yy�w)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.

        r�N)
rj�objectr�rrr�r�r�rKr�r��cascade_iteratorr)r�r�r��halt_on�visited_states�prp�mpp�
visitables�iterator�	item_type�parent_state�parent_dictr%�queuer��instance_mapper�corresponding_state�corresponding_dicts                  rmrUzMapper.cascade_iteratorKs�����@36�%���8�V�X�S���|�|����%�%�%���E�L�L�'�'�.�.�0�1�3��u�z�z�
J�K�
�
��=G��^�:�H�i��{����� ���C���'�'�)���|�|�u�D�L�L�'@��#�/�/�/�"�.�.�.���)�)��$�#�&�������%�%�u�c�4��&>�?��c�!��$�$�&���#�'�&��#�'�&�	���!�!��o�4�4�;�;�=�>��+�*�	��I�s�E&E+�)E+c�@�tj|j�Srh)r!�LRUCacher�r�s rm�_compiled_cachezMapper._compiled_cache�s���}�}�T�6�6�7�7rlc�2�t|j�dkDSr�)rgr�r�s rm�_multiple_persistence_tablesz#Mapper._multiple_persistence_tables�s���4�;�;��!�#�#rlc��
�i�
|jjD]%}|jD]}�
j||���'g}�
j	�D]?\}}|j
}|s�|j
|jD�cgc]}||f��c}��A�
fd�}tj�
||��}tj�}	|D]
}�
||	|<�|	Scc}w)Nc�����j|jj�}�j|jj�}|��|��||ur�|j��tt
j|j��}|j�L|jt
j|j��}|j|vxr|j|vS|j|vSyr2)	r~r�r�rr�rjr�
_find_columnsrB)�fkr��deprW�table_to_mappers    �rm�skipz#Mapper._sorted_tables.<locals>.skip�s����%�(�(������9�F�!�%�%�b�i�i�o�o�6�C��"��O��v�%��)�)�5��8�1�1�#�2G�2G�H�I���+�+�7��:�:� �.�.�v�/G�/G�H��D��9�9�D�0�J�R�Y�Y�d�5J�J��9�9�D�0�0�rl)�skip_fn�extra_dependencies)r�rr��
setdefaultr rr�r�sort_tablesr!rz)r�r�rWrpr��super_�super_tablern�sorted_�retrms          @rm�_sorted_tableszMapper._sorted_tables�s����:<���&�&�;�;�F��]�]���*�*�1�f�5�#�<� ��,�2�2�4�M�E�6��_�_�F��"�)�)�=C�]�]�K�]�k�k�5�)�]�K��5�	�0�&�&���1�
����� ���A�$�Q�'�C��F���
��ILs�C
c��||jvrtt|j|�S|�x|j|<}|Srh)r�r	r_)r�r$�	callable_r�s    rm�_memozMapper._memo�sD���$�'�'�'���D�1�1�#�6�7�7�1:��<�D�!�!�#�&���Lrlc
��tjt�}d�}|jD]�}t	|j
�}|j
�D]r}|js�|jt||jD��cgc]\}}|j��c}}��s�S||j||jf��t��|Scc}}w)zgmemoized map of tables to collections of columns to be
        synchronized upwards to the base mapper.c�$�|j|�Srh)rB)r��ys  rm�	set_unionz+Mapper._table_to_equated.<locals>.set_union�s���7�7�1�:�rl)r!�defaultdictrrwrjr�rr�rerrbr)r�rbr~r�rWr�r��rs        rm�_table_to_equatedzMapper._table_to_equated�s���
���T�"�	�	��(�(�E��u�w�w�<�D��)�)�+���,�,��1B�1B��!�12�1J�1J�K�1J���A����1J�K��2��5�M�(�(�!�Q�-F�-F�)G�H�,�)��
��Ls�C
)NNNFNNNFNNNNNFNFNTTNNNTFTr�F�d):rzr{r|�Optional[FromClause]r z+Optional[Mapping[str, MapperProperty[Any]]]r}z/Optional[Iterable[_ORMColumnExprArgument[Any]]]ryr~rz'Optional[Union[Mapper[Any], Type[Any]]]r�z)Optional[_ColumnExpressionArgument[bool]]r�z/Optional[Sequence[_ORMColumnExprArgument[Any]]]r�r~r�z%Optional[_ORMColumnExprArgument[Any]]r�r�r�zFOptional[Union[_ORMColumnExprArgument[Any], str, MapperProperty[Any]]]r�z Optional[Dict[Any, Mapper[Any]]]r�r�r�r~r��Optional[_WithPolymorphicArg]r�r~r�z'Optional[Literal['selectin', 'inline']]r�r~r�r~r�r�r��Optional[Sequence[str]]r�r�r�r~r�r~r�r~r�zLiteral[True, False, 'auto']r�r~r��int)�return�
Mapper[_O])r�rQ)r�r�r��None�r�r�)r�rr$rr�zColumn[Any])F)r$rr�z3Union[KeyedColumnElement[Any], MapperProperty[Any]]r,r~rwr~r�r~r�rb)r$rrzAUnion[Sequence[KeyedColumnElement[Any]], KeyedColumnElement[Any]]r��ColumnProperty[Any])NN)r$rr�rbrsr~rtzOptional[ColumnProperty[Any]]r�r�r�r�)r$rrzKeyedColumnElement[Any]r�r�)r$rr%z'Union[Column[Any], MapperProperty[Any]]r�r�)r�r)r�rr�rr�r�)r��InstanceState[_O]r�r~)r$rr�r~)r$rrr~r�rb)rzColumnElement[_T]r�zMapperProperty[_T])rrrr�r��Sequence[Mapper[Any]])rzIterable[Mapper[Any]]rr~r�r])r�r~)r�r�)r�r])r�z+Mapping[FromClause, FrozenSet[Column[Any]]])r�z#Mapping[FromClause, FrozenSet[str]])r�zSet[str])NFF)rrrz'Union[Literal[False, None], FromClause]rr~r�z(Tuple[Sequence[Mapper[Any]], FromClause])rk)r�zOptional[orm_util.ORMAdapter]rh)r�z,util.ReadOnlyProperties[MapperProperty[Any]])r�z'util.ReadOnlyProperties[InspectionAttr])r�zDict[str, str])r�z-util.ReadOnlyProperties[SynonymProperty[Any]])r�z,util.ReadOnlyProperties[ColumnProperty[Any]])r�z2util.ReadOnlyProperties[RelationshipProperty[Any]])r�z/util.ReadOnlyProperties[CompositeProperty[Any]])r�z	Type[_MP]r�zutil.ReadOnlyProperties[_MP])r�rY)r�rr�rr�r~)r�rer�r~)r�zInstanceState[Any]r�r~r�r~�r�zIterator[Mapper[Any]])r�re)r�zUnion[Row[Any], RowMapping]rnr�r{zOptional[ORMAdapter]r��_IdentityKeyType[_O])r}�Tuple[Any, ...]rnr�r�r�)r�r"r�r�)r�r�r�r&r�r�)r�r"r�r�)
r�r�r�rHr�ColumnElement[Any]r�r&r�r)r�rr�r�rVz.Optional[Callable[[InstanceState[Any]], bool]]r�zGIterator[Tuple[object, Mapper[Any], InstanceState[Any], _InstanceDict]])r$rryzCallable[[], _T]r�r_)�r�r��__qualname__�__doc__�__annotations__rIrwrHr!�deprecated_paramsr�r�r��	is_mapper�represents_outer_join�propertyr�r�r��non_memoized_property�
deprecatedr��memoized_propertyr�r�r�r
r&r(r�rLrSr�r�r�r�rD�memoized_attributer�r�r��preload_moduler"r}r{rr��langhelpers�tag_method_for_warningsr��	SAWarningr�r�r�r�r�r�r�r�r�r�rrrrrrrr r'r*r,r.r0rEr3�with_polymorphic_mappersr:r>rArErGrKrPr�rZrc�memoized_instancemethodrlrprrsrvr|rrxrur�r�r�r�rer�r�r�r�r�r�r�r�r!r�r�r�rrrr�r�r�r�r�r�r�r&�PASSIVE_RETURN_NO_VALUEr�r�r�rir�r�r�rrr
rr
r'r*r,r1r7rPrRrUrergrwrzr�rkrlrmruru�sf��	�%�$��O�"��s�"� ���T���
�	�-1�BF�GK�!�<@�GK�
�$�@D�
�
�=A�.2��:>�%*�DH�"&��'+�6:�6:� $� %�%)�7=�!&�$'�I^
B��^
B�*�^
B�@�	^
B�
E�^
B��
^
B�:�^
B�E�^
B�
�^
B��^
B�>�^
B�
�^
B�"
�#^
B�(;�)^
B�*,�+^
B�,�-^
B�.8�/^
B�0#�1^
B�2B�3^
B�4 �5^
B�6�7^
B�8%�9^
B�:4�;^
B�<4�=^
B�>�?^
B�@�A^
B�B#�C^
B�D5�E^
B�F�G^
B�H"�I^
B�	�^
B�@
'���I�%�!����
��������
��A���0�0�5�5�2�2�7�7�!�!�(�(�B�B�D�D�6�6�4�4�%�%�L�L�%��
"�!�
�D�C������0�0���P�O����0#�"��2$�#��
5�4��J���	��N��)�(��.$�#��
�L�����6�5��,�+�
�(�'�
���
�8�7�� 2�1�4�	����T�_�_�U�5�6�'�7� �'�
���-��-�}�~%(� =�%(�	
�%(�N�A�61�[�z5��.}
�~r�hD2�L&*�"��#�#��$���#�#�
�$�
��#�#�/�$�/��T���:�;��<��8�T���:�;���"'�h�
�h�F�h�
�h��
h� �h�
�h�<�h�T9�
�9�
�9�
�
9�H8<�;?�
@�
�@�+�@��	@�
5�@�9�
@�
�@�D�T���:�;�"�
�"�(�"�
�	"�<�"�H
���-�-�	�	���	�A�
�A��.*�*��*�E�*�	
�*�")��
��
�C�D�I�	
��("�49����,0��	��".�'�.�	�.��*��*�
"��"�%9�"�	�"�H�,��9=��	��:�#�#��$��"�#�#��$���#�#�
�$�
��#�#�.
�$�.
�`�#�#�?�$�?��#�#�
 �$�
 �'�
�'�
� 9���
'�
�'�
��#�#�
�$�
��#�#�
�$�
��#�#�
�$�
��#�#�
�$�
��#�#�
�	4�
�$�
�$�#�#�
�	4�
�$�
�$�#�#�
�$�
��#�#�
�	,�
�$�
��#�#��$�� �(�(�
�)�
�.
���
��
� �	1��	1��>C��	N��N�<�N��	N�

2�N�0�#�#�
�$�
��

��

�
��#�#�
�$�
��8�#�#�#4�$�#4�J�#�#�C
�$�C
�J�#�#��T���:�;�
�<�$�
� �#�#��T���:�;�
I�<�$�
I������#�#�B�$�B��#�#��T���7�8�
�	;�
�9�$�
�:�#�#��T���:�;�

�<�$�

�
��
�	%�
��#�#�
�$�
�$�#�#�"�$�"�H?��#�#�D�$�D�,�\5�	
�-�'�-�9=�-�	
�-����#�#�
.�$�
.�/�)��5��5�	�)-�(,�	
�
(�
�&�
�&�	
�

�
�H)-�
�$�
�&�
�
�	
�"M�& +�B�B�
� �
��
�
�	
�$� �#�#��$��$�#�#�I�$�I��#�#��$���#�#��$���#�#�N�$�N� +�B�B�O� �O��O�#�	O�
�O�

�
O�N�D�
�-8�,O�,O�
�d
�L��#�#��$��6�p�,�T���:�;�_*�<�_*�B�#�#�B�$�B�CG�	_��_�!�_�@�	_�

�_�B�#�#�8�$�8��#�#�$�$�$��#�#�0�$�0�d�
�����rlrur�c��eZdZy)rN)r�r�r�rkrlrmrrs��rlrc�.�tt�d��y)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.

    Tr�N)r�rnrkrlrm�configure_mappersr�s��H�/�+�T�:rlc��|D]}|js�nyt5tr
	ddd�yda	|D]}|js�n
	daddd�ytjjt�j
�t||�da	ddd�tjjt�j�y#dawxYw#1swY�BxYw)NTF)	r�ri�_already_compilingrurv�
_for_class�before_configured�_do_configure_registries�after_configured)�
registriesr�rqs   rmr�r�Zs����������	�	���
�	�"��	'�!���#�#��"��"'��+
�	�
�O�O�&�&�v�.�@�@�B�
%�Z��9�!&��+
�,�O�O���v�&�7�7�9��"'���+
�	�s9�C�C�C�C�C�=C�C�C�C�Czsqlalchemy.orm.decl_apic�h�tjjj}t	|�}|j
|�D�]5}d}|j
�D]�}d}|jjD]!}|||j�}|tus�d}n|tur�Ht|dd�r8tjd|�d|j���}	|j|	_|	�|jr��	|j!�|j#�|jj%||j���|sd|_|r��|j0j3|�s��#tjd��y#t&$r,t)j*�d}
t-|
d�s|
|_�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_dependenciesrprv�before_mapper_configuredrzr)r�r�r5rwr�r�r��mapper_configured�	Exception�sys�exc_infor>r��
_dependenciesr�)r�r�rK�origrq�has_skipr��
run_configure�fnr5rs           rmr�r�|s����~�~�*�*�3�3�H��z�?�D�2�x�2�2�:�>�����/�/�1�F� �M��o�o�>�>�� "�6�6�=�=� 9�
� �H�,�#�H��	?�
��(���v�2�E�:��.�.�
�v�7�7�	9���'-�&>�&>��#����$�$���5�5�7��/�/�1��O�O�5�5�f�f�m�m�L�52�@�$�C���3�,�,�7�7��=��,�,�/��
�O?��<!���,�,�.��+�C�"�3�(;�<�36��0��	�s
�3AE<�<5F1c��tjjj}t	|�}|j
|�D]�}|s0|jj|�rtjd��|jr<	|jj�\}}|j|�|jr�<|jj�|jj�|j D]}|jj#|��|j j�d|_��y#t$rY��wxYw)Nz^Registry has dependent registries that are not disposed; pass cascade=True to clear these alsoF)r!r�r�rKrj�_recurse_with_dependents�_dependentsr�r�r5�	_managers�popitem�_dispose_manager_and_mapperrN�_non_primary_mappers�clearr��discardr�)r�r�rKr�rqrC�_rls        rm�_dispose_registriesr��s���~�~�*�*�3�3�H��z�?�D�0�x�0�0��<���3�?�?�5�5�d�;��,�,�8��
�
�m�m�
9� �]�]�2�2�4�
���
�/�/��8��m�m�	� � �&�&�(��������$�$�C��O�O�#�#�C�(�%������!�
!���3=���
��
�s�E�	E�Ec��d|_|S)a�Decorate 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)r�s rm�
reconstructorr��s��4#�B��
�IrlT��include_removes�include_backrefsc�����d���fd�}|S)a�Decorate 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)r�r�r��namess ���rm�wrapzvalidates.<locals>.wraps"���$���.� 0�%
��!��	rl)r�rcr�rcrk)r�r�r�r�s``` rm�	validatesr��s���P��Krlc��|jj}|jr |j|j��yyrh)rCr�r�r�)r��ctx�instrumenting_mappers   rmr@r@$s4�� �=�=�/�/���*�*��+�+�E�I�I�K�8�+rlc��|jj}|r/|j�|jr|j|�yyy)z�Run 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)rCr�r�r�)r�r��kwargsr�s    rmr<r<+sD��!�=�=�/�/����-�-�/��9�9� �:�:�5�A�:�rlc� �eZdZdZdZd�Zd�Zy)r�z4Error reporting helper for mapper._columntoproperty.�r�c��||_yrhr�r�s  rmr�z_ColumnMapping.__init__@s	����rlc
�.�|jjj|�}|rItjd|j
j�d|j�d|j�d|����tjd|�d|j�d���)NzColumn 'r�z1' is not available, due to conflicting property 'z':z
No column z is configured on mapper z...)r�r�r~�orm_exc�UnmappedColumnErrorr�rFr$)r�rr%s   rm�__missing__z_ColumnMapping.__missing__Dsx���{�{�!�!�%�%�f�-����-�-��<�<�$�$�f�k�k�6�:�:�t�E��
�
�)�)��t�{�{�
$�
�	
rlN)r�r�r�r��	__slots__r�r�rkrlrmr�r�;s��>��I��
rlr�)r�rb)r�z
Set[registry]r�r�)r�zSet[_RegistryType]r�r~r�r�)r�rr�r~r�r~r�zCallable[[_Fn], _Fn])�r��
__future__r�collectionsr�	functoolsr�	itertoolsrr��	threading�typingrrr	r
rrr
rrrrrrrrrrrrr�weakrefrurrr�rrr r!r��_typingr"r8r#r$r%r&r'�
interfacesr(r)r*r+r,r-r.�
path_registryr/r1r�r2r3r4r5r6r7rxr9r:r;r<r=rr>�
sql.cache_keyr?�sql.elementsr@�
sql.schemarArB�sql.selectablerCrDrE�util.typingrFrGrHrIrJ�decl_apirK�
dependencyrLr�rMrN�eventsrOrPrQrRr�rSr�rTrU�enginerVrW�sql._typingrXrY�sql.baserZr[r\r]r^r_rarc�_WithPolymorphicArg�WeakKeyDictionaryrfr�rnrrr��symbolrs�RLockri�_self_inspects�class_logger�
Identified�Inspectablerur�rr�r�r�r�r�r�r�r@r<r�rkrlrm�<module>r�sS���#����
������������������� �����������"�(����(� �&�&�2�)�+�'����������"������"��/�-���;��4�!��)�&�/�&�"�/�3�1�$�-�4�*�3�$� ��#�7�2�3�+�,�+�!�
�T����
�e�0�1��
�e�/�0����C�L�	�
�g�c�l�H�U�=�$�s�)�+C�%D�E�E�F����	 ��
�U�=�$�s�)�+�
,�-�/����G�����B��
'�
/�
���t�{�{�>�*��#�9�?�?�$��������h=���r�"����N�N����<�(���B�K�h=���h=�V{	��	�D;�N:�"�:�-1�:�	�:�D����.�/�1�"�1�-1�1�	�1�0�1�h����.�/�!�0�!�B�>*/��0��0�"&�0�BF�0��0�f9�
B� 
�T�E�F�
rl

ZeroDay Forums Mini