HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/sqlalchemy/orm/__pycache__/properties.cpython-310.pyc
o

���g�q�@s~dZddlmZddlmZddlmZddlmZddlmZddlmZddlm	Z	dd	lm
Z
dd
lmZddlmZddlm
Z
dd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddl"m#Z#ddl$m%Z%d d!lm&Z'd d"lm(Z(d d#lm)Z)d d$lm$Z$d d%l*m+Z+d d&l*m,Z,d d'l-m.Z.d d(l/m0Z0d d)l/m1Z1d d*l2m3Z3d d+l4m5Z5d d,l4m6Z6d d-l4m7Z7d d.l4m8Z8d d/l4m9Z9d d0l4m:Z:d d1l4m;Z;e
�rydd2l<m=Z=dd3l<m>Z>dd4l<m?Z?dd5l<m@Z@dd6lmAZAdd7lBmCZCdd8lDmEZEdd9lFmGZGdd:lHmIZIdd;lHmJZJd d<lKmLZLd d=lMmNZNd d>lMmOZOd d?lPmQZQd d@l4mRZRd dAl4mSZSedBedC�ZTedDedC�ZUedEdFdC�ZVgdG�ZWe)jXGdHdI�dIeeTe!eTee)jY��ZZGdJdK�dKeZeTeeT�Z[GdLdM�dMeeeTeeT�Z\dNS)Oz|MapperProperty implementations.

This is a private module which defines the behavior of individual ORM-
mapped attributes.

�)�annotations)�Any)�cast)�Dict)�List)�Optional)�Sequence)�Set)�Tuple)�Type)�
TYPE_CHECKING)�TypeVar)�Union�)�
attributes)�strategy_options)�_DeclarativeMapped)�class_mapper)�CompositeProperty)�ConcreteInheritedProperty)�SynonymProperty)�_AttributeOptions)�_DEFAULT_ATTRIBUTE_OPTIONS)�_IntrospectsAnnotations)�_MapsColumns)�MapperProperty)�PropComparator)�StrategizedProperty)�RelationshipProperty)�de_stringify_annotation�)�exc)�
ForeignKey)�log)�util)�	coercions)�roles)�_NoArg)�Column)�SchemaConst)�
TypeEngine)�de_optionalize_union_types)�get_args)�
includes_none)�
is_fwd_ref)�	is_pep593)�	is_pep695)�Self)�_IdentityKeyType)�
_InstanceDict)�_ORMColumnExprArgument)�
_RegistryType)�Mapped)�_ClassScanMapperConfig)�Mapper)�Session)�_InstallLoaderCallableProto)�
InstanceState)�	_InfoType)�
ColumnElement)�NamedColumn)�OperatorType)�_AnnotationScanType)�RODescriptorReference�_T)�bound�_PT�_NCzNamedColumn[Any])�ColumnPropertyrrrrcs4eZdZUdZejZdZ	dZde	d<de	d<de	d	<d
e	d<dZ
d
d
ddd
ddd
d
ddd�de�fd d!�Zdfd3d4�Ze
dgd6d7��Ze
dhd9d:��Zdid;d<�Ze�d=d>�djd@dA��Ze�d=d>�djdBdC��ZdkdEdF�Ze
dkdGdH��ZdldKdL�Zdm�fdMdN�ZdndPdQ�Zdod_d`�ZGdadb�dbejee�Zdpdcdd�Z�Z S)qrFz�Describes an object attribute that corresponds to a table column
    or other column expression.

    Public constructor is the :func:`_orm.column_property` function.

    TFzList[NamedColumn[Any]]�columns�bool�_is_polymorphic_discriminator�
Optional[str]�_mapped_by_synonymzType[PropComparator[_T]]�comparator_factory)rG�group�deferred�
instrumentrL�active_history�expire_on_flush�_creation_orderrIrK�_deferred_column_loader�_raise_column_loader�_renders_in_subqueries�	raiseloadN)�attribute_optionsrMrNrVrLrPrQ�info�doc�_instrument�_assume_readonly_dc_attributes�column�_ORMColumnExprArgument[_T]�additional_columns�_ORMColumnExprArgument[Any]rW�Optional[_AttributeOptions]rMrNrV�"Optional[Type[PropComparator[_T]]]rPrQrX�Optional[_InfoType]rYrZr[cs�t�j||d�|f|
}dd�|D�|_||_||_||_||_|dur'|n|jj|_	||_
||_|	dur<|j�
|	�|
durD|
|_nt|j�D]}t|dd�}
|
durZ|
|_nqId|_t�|�d|jfd|jff|_|jrz|jd7_dSdS)N)rWr[cSsg|]	}t�tj|��qS�)r%�expectr&�LabeledColumnExprRole��.0�crcrc�D/usr/local/lib/python3.10/dist-packages/sqlalchemy/orm/properties.py�
<listcomp>�s�z+ColumnProperty.__init__.<locals>.<listcomp>rYrNrO))rVT)�super�__init__rGrMrNrVrO�	__class__�
ComparatorrLrPrQrX�updaterY�reversed�getattrr$�set_creation_order�strategy_key)�selfr\rWrMrNrVrLrPrQrXrYrZr[r^rG�col�rmrcrirl�sH�
����
��zColumnProperty.__init__�	decl_scanr7�registryr5�cls�	Type[Any]�originating_module�key�str�mapped_container�Optional[Type[Mapped[Any]]]�
annotation�Optional[_AnnotationScanType]�extracted_mapped_annotation�is_dataclass_field�return�Nonec
Cs2|jd}
|
jdur
||
_|
jdur||
_dSdS�Nr)rGr|�name)rtrwrxryr{r|r~r�r�r�r\rcrcri�declarative_scan�s



�zColumnProperty.declarative_scan�Optional[MapperProperty[_T]]cCs|S�Nrc�rtrcrcri�mapper_property_to_assign�sz(ColumnProperty.mapper_property_to_assign�List[Tuple[Column[Any], int]]cCsdd�|jD�S)NcSs(g|]}t|t�r|jdur|df�qSr�)�
isinstancer(�tablerfrcrcrirj�s�
�z4ColumnProperty.columns_to_assign.<locals>.<listcomp>�rGr�rcrcri�columns_to_assign�s�z ColumnProperty.columns_to_assigncCs(d|jvr	|jjSd|jvp||jjvS)N)�query_expressionT)rNT)rs�strategy�_have_default_expression�parent�_readonly_propsr�rcrcri�%_memoized_attr__renders_in_subqueries�s



�z4ColumnProperty._memoized_attr__renders_in_subquerieszsqlalchemy.orm.statezsqlalchemy.orm.strategies� _InstallLoaderCallableProto[Any]cCs.tjj}tjj}|j�|jj|�|j	�|j	�Sr��
r$�	preloaded�	orm_state�orm_strategiesr;�"_instance_level_callable_processorr��
class_manager�LoadDeferredColumnsr|�rt�state�
strategiesrcrcri�&_memoized_attr__deferred_column_loader�s
�z5ColumnProperty._memoized_attr__deferred_column_loadercCs0tjj}tjj}|j�|jj|�|j	d�|j	�S)NTr�r�rcrcri�#_memoized_attr__raise_column_loader�s�z2ColumnProperty._memoized_attr__raise_column_loader�roles.ColumnsClauseRolecC�|jS)zsAllow the ColumnProperty to work in expression before it is turned
        into an instrumented attribute.
        )�
expressionr�rcrcri�__clause_element__sz!ColumnProperty.__clause_element__cCs
|jdS)a�Return the primary column or expression for this ColumnProperty.

        E.g.::


            class File(Base):
                # ...

                name = Column(String(64))
                extension = Column(String(8))
                filename = column_property(name + "." + extension)
                path = column_property("C:/" + filename.expression)

        .. seealso::

            :ref:`mapper_column_property_sql_expressions_composed`

        rr�r�rcrcrir�
s
zColumnProperty.expression�mapper�Mapper[Any]cCs0|jsdStj|j|j|�||�||jd�dS)N)�
comparator�parententityrY)rOr�register_descriptor�class_r|rLrY)rtr�rcrcri�instrument_class#s

�zColumnProperty.instrument_classcs^t���t|j�dkr+t|jj��|j�r-t�	d|j|jd|jd|j
f�dSdSdS)Nrz�On mapper %s, primary key column '%s' is being combined with distinct primary key column '%s' in attribute '%s'. Use explicit properties to give each column its own mapped attribute name.r)rk�do_init�lenrG�setr��primary_key�
issupersetr$�warnr|r�rvrcrir�/s
����zColumnProperty.do_init�ColumnProperty[_T]cCst|j|j|j|jd��S)N)rNrMrP)rFrGrNrMrPr�rcrcri�copy?s�zColumnProperty.copy�sessionr9�source_state�InstanceState[Any]�source_dictr3�
dest_state�	dest_dict�load�
_recursive�Dict[Any, object]�_resolve_conflict_map�#Dict[_IdentityKeyType[Any], object]c	Cs�|jsdS|j|vr(||j}	|s|	||j<dS|�|j�}
|
�|||	d�dS|jr<|j|vr>|j||jgdd�dSdSdS)NT)�	no_loader)rOr|�get_implr��has_identity�_expire_attributes)rtr�r�r�r�r�r�r�r��value�implrcrcri�mergeGs



��zColumnProperty.mergec@s�eZdZUdZesdZded<ded<	d%d
d�Zer d&d
d�Zd&dd�Z	d'dd�Z
d(dd�Zd)dd�Zd*d d!�Z
d*d"d#�Zd$S)+zColumnProperty.Comparatora�Produce boolean, comparison, and other operators for
        :class:`.ColumnProperty` attributes.

        See the documentation for :class:`.PropComparator` for a brief
        overview.

        .. seealso::

            :class:`.PropComparator`

            :class:`.ColumnOperators`

            :ref:`types_operators`

            :attr:`.TypeEngine.comparator_factory`

        )r�rX�expressionsz*RODescriptorReference[ColumnProperty[_PT]]�prop�Sequence[NamedColumn[Any]]r�r\rEr�cCsT|j}||||jjd�}|}|jjr|}|jj�|�}||d<|�|��d|d��S)a�annotate and possibly adapt a column to be returned
            as the mapped-attribute exposed version of the column.

            The column in this context needs to act as much like the
            column in an ORM mapped context as possible, so includes
            annotations to give hints to various ORM functions as to
            the source entity of this column.   It also adapts it
            to the mapper's with_polymorphic selectable if one is
            present.

            )�entity_namespacer��parentmapper�	proxy_key�adapt_column�orm)�compile_state_plugin�plugin_subject)�
_parententityr�r|�
_parentmapper�_polymorphic_adapter�traverse�	_annotate�_set_propagate_attrs)rtr\�perru�mapper_local_colrcrcri�_orm_annotate_column�s
�
�z.ColumnProperty.Comparator._orm_annotate_column�NamedColumn[_PT]cCsdSr�rcr�rcrcrir��sz,ColumnProperty.Comparator.__clause_element__cCs0|jr|�|jjd|jj�S|�|jjd�Sr�)�adapterr�rGr|r�r�rcrcri�#_memoized_method___clause_element__�sz=ColumnProperty.Comparator._memoized_method___clause_element__r<cCs,|��}z|jWSty|jjYSw)z(The .info dictionary for this attribute.)r�rX�AttributeErrorr�)rt�cercrcri�_memoized_attr_info�s�z-ColumnProperty.Comparator._memoized_attr_infocs2�jr�fdd��jjD�S�fdd��jjD�S)z�The full sequence of columns referenced by this
            attribute, adjusted for any aliasing in progress.

            .. versionadded:: 1.3.17

            csg|]
}��|�jj��qSrc)r�r�r|�rgrur�rcrirj�s��zHColumnProperty.Comparator._memoized_attr_expressions.<locals>.<listcomp>csg|]}��|��qSrc)r�r�r�rcrirj�s
�)r�r�rGr�rcr�ri�_memoized_attr_expressions�s
�
�z4ColumnProperty.Comparator._memoized_attr_expressionsr|r}rcCst|��|�S)z�proxy attribute access down to the mapped column.

            this allows user-defined comparison methods to be accessed.
            )rqr�)rtr|rcrcri�_fallback_getattr�sz+ColumnProperty.Comparator._fallback_getattr�opr?�other�kwargs�ColumnElement[Any]cO�||��g|�Ri|��Sr��r��rtr�r�r�rcrcri�operate��z!ColumnProperty.Comparator.operatecK�"|��}||�||�|fi|��Sr��r��_bind_param�rtr�r�r�rurcrcri�reverse_operate��z)ColumnProperty.Comparator.reverse_operateN)r\rEr�rE)r�r�)r�r<)r�r�)r|r}r�r�r�r?r�rr�rr�r�)�__name__�
__module__�__qualname__�__doc__r�	__slots__�__annotations__r�r�r�r�r�r�r�r�rcrcrcrirnas 


(



	

rncCs.|jr|jst�|�St|jjj�d|jS)N�.)r�r|�object�__repr__r}r�r�r�rcrcri�__str__�s
zColumnProperty.__str__)r\r]r^r_rWr`rMrJrNrHrVrHrLrarPrHrQrHrXrbrYrJrZrHr[rH�rwr7rxr5ryrzr{rJr|r}r~rr�r�r�r�r�rHr�r��r�r��r�r�)r�rH)r�r�)r�r�)r�r�r�r�)r�r�)r�r�)r�r9r�r�r�r3r�r�r�r3r�rHr�r�r�r�r�r��r�r})!r�r�r�r�r�
_COLUMN_TOKEN�strategy_wildcard_key�
inherit_cache�_links_to_entityr�r�rlr��propertyr�r�r�r$�preload_moduler�r�r�r�r�r�r�r��
MemoizedSlotsrrDrnr��
__classcell__rcrcrvrirF_sV
�
;






rFc@seZdZdZdZdS)�MappedSQLExpressionaNDeclarative front-end for the :class:`.ColumnProperty` class.

    Public constructor is the :func:`_orm.column_property` function.

    .. versionchanged:: 2.0 Added :class:`_orm.MappedSQLExpression` as
       a Declarative compatible subclass for :class:`_orm.ColumnProperty`.

    .. seealso::

        :class:`.MappedColumn`

    TN)r�r�r�r�rrcrcrcrir�s
rc@s�eZdZUdZdZded<ded<ded<d	ed
<ded<d
ed<dIdd�ZdJdd�ZedKdd��Z	edLdd��Z
edMdd ��ZdNd!d"�ZdOd(d)�Z
dOd*d+�ZdPd,d-�ZdQd=d>�Ze�d?�dRdCdD��ZdSdFdG�ZdHS)T�MappedColumna_Maps a single :class:`_schema.Column` on a class.

    :class:`_orm.MappedColumn` is a specialization of the
    :class:`_orm.ColumnProperty` class and is oriented towards declarative
    configuration.

    To construct :class:`_orm.MappedColumn` objects, use the
    :func:`_orm.mapped_column` constructor function.

    .. versionadded:: 2.0


    )
r\rR�_sort_order�foreign_keys�
_has_nullable�_has_insert_defaultrN�deferred_group�deferred_raiseloadrP�_attribute_options�_has_dataclass_arguments�_use_existing_columnzUnion[_NoArg, bool]rNrHrrJr�
Column[_T]r\zOptional[Set[ForeignKey]]rrr�argr�kwcs$|�dt�|_�|�dd�|_�duo%�tko%t�fdd�t�j�D��|_|�dtj	�}|tj	u|_
|j
r<||d<n�jtj	urG�j|d<|�dd�|_|�d	d�|_
|�d
tj	�|_|�dd�|_|�dtj	�|_td
t|i|���|_|jj|_d|vo�|�d�dtjfv|_t�|�dS)NrW�use_existing_columnFc3s*�|]\}}|dkr�|tjuVqdS)�dataclasses_defaultN)r'�NO_ARG)rg�i�attr��	attr_optsrcri�	<genexpr>2s���z(MappedColumn.__init__.<locals>.<genexpr>�insert_default�defaultrrrNrP�
sort_orderr�nullable)�poprrr�any�	enumerate�_fieldsrr'rrrrrrNrPrrr(r\r�getr)�NULL_UNSPECIFIEDrr$rr)rtrrr"rcrrirl(s:
����



�zMappedColumn.__init__r�r1cKs�|j�|j�}|jjdi|��|_|j|_|j|_|j|_|jj|_|j|_|j	|_	|j
|_
|j|_|j|_|j
|_
|j|_t�|�|S)Nrc)rm�__new__r\�_copyrNrrrrPrrrrrrr$rr)rtr�newrcrcrir-Os

zMappedColumn._copyr}cCs|jjSr�)r\r�r�rcrcrir�`szMappedColumn.namer�cCsL|j}|tjurt|jp|j�}|s|jr$t|j||j|j|j	|jd�SdS)N)rNrMrVrWrP)
rNr'rrHrrrPrFr\r)rt�effective_deferredrcrcrir�ds

�
�	z&MappedColumn.mapper_property_to_assignr�cCs"|j|jtjur
|jfgSdfgSr�)r\rr'rr�rcrcrir�xs�����zMappedColumn.columns_to_assigncCr�r�)r\r�rcrcrir��szMappedColumn.__clause_element__r�r?r�r�r�cOr�r�r�r�rcrcrir��r�zMappedColumn.operatecKr�r�r�r�rcrcrir��r�zMappedColumn.reverse_operatecCst�Sr�)r
r�rcrcri�found_in_pep593_annotated�sz&MappedColumn.found_in_pep593_annotatedrwr7rxr5ryrzr{r|r~rr�r�r�r�r�c
Cs�|j}
|jr/|jr/|jr/|jrt�d��t|jd�}|
jdur"|
jn|}|j	j
�||
�}
|_|
jdur7||
_|
jdur?||
_|
j
}
|durV|
jrT|jjsT|�||�ndS|�||||�dS)Nz3Can't use use_existing_column with deferred mappersF)r\r�inherits�single�is_deferred�sa_exc�
ArgumentErrorrr��local_tablerhr*r|�type�_isnullr�_raise_for_required�_init_column_for_annotation)rtrwrxryr{r|r~r�r�r�r\�supercls_mapper�colname�sqltypercrcrir��s>����
�

�zMappedColumn.declarative_scanzsqlalchemy.orm.decl_base�
param_name�param_annotationr@cCs*tjj}|�||j�|�||||�dSr�)r$r��
orm_decl_base�_undefer_column_namer\r:)rtrxryr{r|r>r?�	decl_basercrcri�declarative_scan_for_composite�s

�z+MappedColumn.declarative_scan_for_composite�argumentcCs�|jj}t|ddd�r|dusJ�t|||dd�}t|�}|js$||j_t|�}d}d}	d}
t|�rId}	t	|�}|d}
|rBt|
�}
|dd�}nt
|�r[t|j�r[t	|j�dd�}|D]}t|t
�rh|}
nq]d}
|
du�r
|js}|
jjdur}d|j_|
j�|j�|jj}|
jtjur�|jtjur�|
j|_|
jdur�|jdur�|
j|_|
jdur�|jdur�|
j|_|
jr�|js�d|_|
jr�|
j|_|
jdur�|jtjur�|
j|_|
jjdus�|
jjdur�t�dd	�|
j�r
t|
jj �D]\}}|
j|tju�r|�!d
d�}t�d|�d
�d	�q�|j"�rk|jj#�smd}|	�r ||
g}n|g}|D]}|�$|�}|du�r3n0�q%t|t%��sGt|t��rUt&|t%��rUt'�(d|jj�d|�d���t'�(d|�d|jj�d���|j�)|�dSdSdS)NT)�
check_generic�check_for_plain_string)�include_genericrcFrrz_Can't use the 'key' or 'name' arguments in Annotated with mapped_column(); this will be ignoredz2.0.22�dataclasses_�z
Argument 'zp' is a dataclass argument and cannot be specified within a mapped_column() bundled inside of an Annotated objectzThe type provided inside the z4 attribute Mapped annotation is the SQLAlchemy type z . Expected a Python type insteadz6Could not locate SQLAlchemy Core type for Python type z inside the z attribute Mapped annotation)*r\r7r.rr-rr%r+r/r,r0�	__value__r�r
rr#�_mergerNr'rrrrrPrr|r�r$�warn_deprecatedrr(rr)�replacer8r�
_resolve_typer*�
issubclassr4r5�	_set_type)rtryrxrDr{r=r%�our_type�find_mapped_in�our_type_is_pep593�raw_pep_593_type�pep_593_components�elem�
use_args_from�idxr�new_sqltype�checks�
check_typercrcrir:�s���
�
�



��
���
��


���������z(MappedColumn._init_column_for_annotationN)rrrr)rrr�r1rrr)r�rr�)r�rr)rxr5ryrzr{rJr|r}r>r}r?r@r�r�)
ryrzrxr5rDr@r{rJr�r�)r�r�r�r�r�r�rlr-rr�r�r�r�r�r�r0r�r$r	rCr:rcrcrcrir
�s2


'




2r
N)]r��
__future__r�typingrrrrrrr	r
rrr
rrIrr�baserr�descriptor_propsrrr�
interfacesrrrrrrr�
relationshipsrr$rr!r4r"r#�sqlr%r&�sql.baser'�
sql.schemar(r)�sql.type_apir*�util.typingr+r,r-r.r/r0r1�_typingr2r3r4r5r6rBr7r�r8r�r9r�r:r;�sql._typingr<�sql.elementsr=r>�
sql.operatorsr?r@rArBrDrE�__all__�class_logger�
IdentifiedrFrr
rcrcrcri�<module>s�	
�
�