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__/evaluator.cpython-310.pyc
o

���gA0�@s�dZddlmZddlmZddlmZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
lm
Z
ddlmZddlmZdd
lmZddlmZddlmZGdd�dej�ZGdd�dej�ZGdd�dej�Ze�Ze�ZGdd�d�Zddd�ZdS) z�Evaluation functions used **INTERNALLY** by ORM DML use cases.


This module is **private, for internal use by SQLAlchemy**.

.. versionchanged:: 2.0.4 renamed ``EvaluatorCompiler`` to
   ``_EvaluatorCompiler``.

�)�annotations)�Type�)�exc)�LoaderCallableStatus)�PassiveFlag�)�inspect)�and_)�	operators)�Concatenable)�Integer)�Numeric)�warn_deprecatedc@seZdZdS)�UnevaluatableErrorN)�__name__�
__module__�__qualname__�rr�C/usr/local/lib/python3.10/dist-packages/sqlalchemy/orm/evaluator.pyr%src@�eZdZdd�Zdd�ZdS)�	_NoObjectcO�dS�Nr��self�arg�kwrrr�operate*�z_NoObject.operatecOrrrrrrr�reverse_operate-rz_NoObject.reverse_operateN�rrrrr rrrrr)�rc@r)�_ExpiredObjectcO�|Srrrrrrr2rz_ExpiredObject.operatecOr$rrrrrrr 5rz_ExpiredObject.reverse_operateNr!rrrrr#1r"r#c@s
eZdZd6dd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�ZeZeZeZeZeZeZeZeZeZeZeZ d(d)�Z!d*d+�Z"d,d-�Z#d.d/�Z$d0d1�Z%d2d3�Z&d4d5�Z'dS)7�_EvaluatorCompilerNcCs
||_dSr)�
target_cls)rr&rrr�__init__>�
z_EvaluatorCompiler.__init__cGsH|r
t|g|�R�}t|d|j��d�}|s tdt|�j����||�S)N�visit_�Cannot evaluate )r
�getattr�__visit_name__r�typer)r�clause�clauses�methrrr�processAs�z_EvaluatorCompiler.processcCs|�|j�Sr)r1�element�rr.rrr�visit_groupingLsz!_EvaluatorCompiler.visit_groupingcC�dd�S)NcSrrr��objrrr�<lambda>P�z/_EvaluatorCompiler.visit_null.<locals>.<lambda>rr3rrr�
visit_nullO�z_EvaluatorCompiler.visit_nullcCr5)NcS�dS)NFrr6rrrr8Sr9z0_EvaluatorCompiler.visit_false.<locals>.<lambda>rr3rrr�visit_falseRr;z_EvaluatorCompiler.visit_falsecCr5)NcSr<)NTrr6rrrr8Vr9z/_EvaluatorCompiler.visit_true.<locals>.<lambda>rr3rrr�
visit_trueUr;z_EvaluatorCompiler.visit_truec
s�z|jd}Wnty}ztd|���|�d}~ww|jr.t|j|j�s.td|j����|��z|j|j}Wnt	j
yO}ztd|���|�d}~ww|j|j��fdd�}|S)N�parentmapperzCannot evaluate column: z0Can't evaluate criteria against alternate class zCannot evaluate expression: cs>|durtSt|�}|j}�j||tjd�}|tjurtS|S)N)�passive)	�
_NO_OBJECTr	�dict�getr�PASSIVE_NO_FETCHr�PASSIVE_NO_RESULT�_EXPIRED_OBJECT)r7�state�dict_�value��implrr�get_corresponding_attrs�
z?_EvaluatorCompiler.visit_column.<locals>.get_corresponding_attr)
�_annotations�KeyErrorrr&�
issubclass�class_�_check_configure�_columntoproperty�key�orm_exc�UnmappedColumnError�
class_managerrK)rr.r?�kerS�errrLrrJr�visit_columnXs@�����������
z_EvaluatorCompiler.visit_columncC�
|�|�Sr��visit_clauselistr3rrr�visit_tuple�r(z_EvaluatorCompiler.visit_tuplecCrZrr[r3rrr�visit_expression_clauselist�r(z._EvaluatorCompiler.visit_expression_clauselistcsX�fdd�|jD�}d|jj�d��d�}t�|d�}|r$||j||�Std|j����)Ncsg|]}��|��qSr)r1)�.0r.�rrr�
<listcomp>�sz7_EvaluatorCompiler.visit_clauselist.<locals>.<listcomp>r)�_�_clauselist_opz)Cannot evaluate clauselist with operator )r/�operatorr�rstripr+r)rr.�
evaluators�dispatchr0rr`rr\�s�
�z#_EvaluatorCompiler.visit_clauselistcCsj|�|j�}|�|j�}d|jj�d��d�}t||d�}|r'||j|||�Stdt|�j�d|j����)Nr)rb�
_binary_opr*� with operator )	r1�left�rightrdrrer+rr-)rr.�	eval_left�
eval_rightrgr0rrr�visit_binary�s��z_EvaluatorCompiler.visit_binaryc��fdd�}|S)NcsHd}�D]}||�}|turtS|rdS|p|du}q|r"dSdS�NFT�rF)r7�has_null�sub_evaluaterI�rfrr�evaluate�sz;_EvaluatorCompiler.visit_or_clauselist_op.<locals>.evaluater�rrdrfr.rurrtr�visit_or_clauselist_op�s
z)_EvaluatorCompiler.visit_or_clauselist_opcro)NcsF�D]}||�}|turtS|s |dus|turdSdSqdSrp)rFrA)r7rsrIrtrrru�s�z<_EvaluatorCompiler.visit_and_clauselist_op.<locals>.evaluaterrvrrtr�visit_and_clauselist_op�sz*_EvaluatorCompiler.visit_and_clauselist_opcro)NcsNg}�D]}||�}|turtS|dus|turdS|�|�qt|�Sr)rFrA�append�tuple)r7�valuesrsrIrtrrru�szA_EvaluatorCompiler.visit_comma_op_clauselist_op.<locals>.evaluaterrvrrtr�visit_comma_op_clauselist_op�sz/_EvaluatorCompiler.visit_comma_op_clauselist_opcCs(|jr|�||||�Std|j�d���)NzCustom operator zR can't be evaluated in Python unless it specifies a callable using `.python_impl`.)�python_impl�_straight_evaluater�opstring�rrdrlrmr.rrr�visit_custom_op_binary_op�s��z,_EvaluatorCompiler.visit_custom_op_binary_opc���fdd�}|S)Ncs,�|�}�|�}|tus|turtS||kSrrq�r7�left_val�	right_val�rlrmrrru��
z7_EvaluatorCompiler.visit_is_binary_op.<locals>.evaluater�rrdrlrmr.rurr�r�visit_is_binary_op��z%_EvaluatorCompiler.visit_is_binary_opcr�)Ncs,�|�}�|�}|tus|turtS||kSrrqr�r�rrru�r�z;_EvaluatorCompiler.visit_is_not_binary_op.<locals>.evaluaterr�rr�r�visit_is_not_binary_op�r�z)_EvaluatorCompiler.visit_is_not_binary_opcs���fdd�}|S)NcsJ�|�}�|�}|tus|turtS|dus|durdS��|��|��Srrqr��rlrmrdrrrusz7_EvaluatorCompiler._straight_evaluate.<locals>.evaluaterr�rr�rr~�s
z%_EvaluatorCompiler._straight_evaluatecCsX|jjjttfvs|jjjttfvr$td|j�d|jj�d|jj����|�||||�S)NzCannot evaluate math operator "�" for datatypes �, )	rjr-�_type_affinityrr
rkrrr~r�rrr�_straight_evaluate_numeric_onlys�
���z2_EvaluatorCompiler._straight_evaluate_numeric_onlycC�|�dd�|||�S)NcSs|tur||vSdSr�rA��a�brrrr8(�z:_EvaluatorCompiler.visit_in_op_binary_op.<locals>.<lambda>�r~r�rrr�visit_in_op_binary_op&s�z(_EvaluatorCompiler.visit_in_op_binary_opcCr�)NcSs|tur||vSdSrr�r�rrrr82r�z>_EvaluatorCompiler.visit_not_in_op_binary_op.<locals>.<lambda>r�r�rrr�visit_not_in_op_binary_op.s�z,_EvaluatorCompiler.visit_not_in_op_binary_opcCsXt|jjjt�rt|jjjt�s"td|j�d|jj�d|jj����|�dd�|||�S)Nz&Cannot evaluate concatenate operator "r�r�cSs||Srrr�rrrr8Fsz>_EvaluatorCompiler.visit_concat_op_binary_op.<locals>.<lambda>)	rOrjr-r�rrkrrr~r�rrr�visit_concat_op_binary_op8s"
�������z,_EvaluatorCompiler.visit_concat_op_binary_opcCr�)NcSrZr)�
startswithr�rrrr8M�
zB_EvaluatorCompiler.visit_startswith_op_binary_op.<locals>.<lambda>r�r�rrr�visit_startswith_op_binary_opI��z0_EvaluatorCompiler.visit_startswith_op_binary_opcCr�)NcSrZr)�endswithr�rrrr8Tr�z@_EvaluatorCompiler.visit_endswith_op_binary_op.<locals>.<lambda>r�r�rrr�visit_endswith_op_binary_opPr�z._EvaluatorCompiler.visit_endswith_op_binary_opcsD|�|j��|jtjur�fdd�}|Stdt|�j�d|j����)Ncs&�|�}|tur
tS|durdS|Srrq)r7rI��
eval_innerrrru[sz0_EvaluatorCompiler.visit_unary.<locals>.evaluater*ri)r1r2rdr�invrr-r)rr.rurr�r�visit_unaryWs��z_EvaluatorCompiler.visit_unarycs"|jr|���n|j��fdd�S)Ncs�Srrr6��valrrr8nr9z4_EvaluatorCompiler.visit_bindparam.<locals>.<lambda>)�callablerIr3rr�r�visit_bindparamis
z"_EvaluatorCompiler.visit_bindparamr)(rrrr'r1r4r:r=r>rYr]r^r\rnrwrxr|r�r�r�r~r��visit_add_binary_op�visit_mul_binary_op�visit_sub_binary_op�visit_mod_binary_op�visit_truediv_binary_op�visit_lt_binary_op�visit_le_binary_op�visit_ne_binary_op�visit_gt_binary_op�visit_ge_binary_op�visit_eq_binary_opr�r�r�r�r�r�r�rrrrr%=sL
6



r%�name�str�return�Type[_EvaluatorCompiler]cCs*|dkrtdd�tStdt�d|����)N�EvaluatorCompilerz�Direct use of 'EvaluatorCompiler' is not supported, and this name will be removed in a future release.  '_EvaluatorCompiler' is for internal use onlyz2.0zmodule z has no attribute )rr%�AttributeErrorr)r�rrr�__getattr__qs�r�N)r�r�r�r�)�__doc__�
__future__r�typingr�rrT�baserrr	�sqlr
r�sql.sqltypesrr
r�utilr�InvalidRequestErrorr�ColumnOperatorsrr#rArFr%r�rrrr�<module>s.6