o
    Rc-                     @   sp  d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 dd	lm
Z
 dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddejefddfddZdiddZdiddZdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Z d-d. Z!d/d0 Z"d1d2 Z#d3d4 Z$i d5efd6efd7efd8efd9efd:efd;efd<efd=efd>efd?efd@efdAefdBeej%fdCeej&fdDeej'fdEeej(fi dFeej)fdGeej*fdHeej+fdIeej,fdJeej-fdKeej.fdLeej/fdMeej0fdNeej1fdOeej2fdPeej3fdQeej4fdReej5fdSeej6fdTeej7fdUeej8fdVeej9fi dWeej:fdXeej;fdYeej<fdZeej=fd[e"fd\efd]efd^e fd_e!fd`e!fdaefdbefdcefddefdeefdfe#fdge#fdhe$fiZ>dS )jz5Default implementation of SQL comparison operations.
   )	coercions)	operators)roles)type_api)and_)BinaryExpression)
ClauseListcollate)CollectionAggregate)False_)Null)or_)True_)UnaryExpression   )exc)utilNFc           	      K   sR  |d u rt j}t||tttf r|tjtjfv r0t|t	ttfr0t
| ttj|||||dS |tjtjfv rGt
| ttj|||||dS |rTtjtj||| d}n?|tjtjfv rlt
| ttj|tjtj|dS |tjtjfv rt
| ttj|tjtj|dS tdtjtj||| d}|rt
|| ||||dS t
| |||||dS )N)type_negate	modifiers)elementoperatorexpr)r   r   z~Only '=', '!=', 'is_()', 'is_not()', 'is_distinct_from()', 'is_not_distinct_from()' operators can be used with None/True/False)r   BOOLEANTYPE
isinstancer   r   r   r   eqneboolr   r   expectr   ZConstExprRoleis_distinct_fromis_not_distinct_fromis_is_notr   ArgumentErrorBinaryElementRole)	r   opobjr   reverseZ_python_is_typesZ_any_all_exprresult_typekwargs r+   CD:\Flask\env\Lib\site-packages\sqlalchemy/sql/default_comparator.py_boolean_compare   sv   


r-   c                 K   s<   |d u r|j r|j }n|jrtj}t| ||f||d|S )N)r(   r)   )return_typeZis_comparisonr   r   _binary_operate)r   r&   r'   r(   r)   kwr+   r+   r,   _custom_op_operates   s   r1   c                 K   s\   t jtj|| |d}|r|| }}n| |}}|d u r%|j||j\}}t|||||dS )Nr   r   )r   r   )r   r   r   r%   Z
comparatorZ_adapt_expressionr   )r   r&   r'   r(   r)   r0   leftrightr+   r+   r,   r/      s   

r/   c                 K   s.   |t ju r
t| |S |t ju rt| |S t N)r   r   r   NotImplementedErrorr   r&   otherr0   r+   r+   r,   _conjunction_operate   s
   



r9   c                 K   s   || S r5   r+   )r   r&   fnr0   r+   r+   r,   _scalar   s   r;   c                 K   sD   t jtj|| |d}d|jv r|jd \}}t| ||fd|i|S )Nr2   Zin_opsr   )r   r   r   ZInElementRoleZ_annotationsr-   )r   r&   Zseq_or_selectableZ	negate_opr0   r+   r+   r,   _in_impl   s   

r<   c                 K   sl   t | jtjst | jtjr*t | jjtjr*tjtj	|| |d}t
| ||fi |S t| ||fi | d S )Nr2   )r   typer   Z	INDEXABLEZTypeDecoratorimplr   r   r   r%   r/   _unsupported_implr7   r+   r+   r,   _getitem_impl   s   
r@   c                 O   s   t d|j )Nz1Operator '%s' is not supported on this expression)r6   __name__)r   r&   argr0   r+   r+   r,   r?      s   r?   c                 K   s   t | dr| jS |  S )z%See :meth:`.ColumnOperators.__inv__`.negation_clause)hasattrrC   Z_negater   r&   r0   r+   r+   r,   	_inv_impl   s   
rF   c                 K      t | tj| jdS )z%See :meth:`.ColumnOperators.__neg__`.r   r   )r   r   negr=   rE   r+   r+   r,   	_neg_impl   s   rJ   c              	   K   sB   t | tjtjtj|| tjdftj|tju rtj	ntjd|S )z#See :meth:`.ColumnOperators.match`.r2   )r)   r   )
r-   r   match_opr   r   r   r%   r   Z	MATCHTYPEnot_match_opr7   r+   r+   r,   _match_impl   s"   	rM   c                 K   rG   )z&See :meth:`.ColumnOperators.distinct`.rH   )r   r   distinct_opr=   rE   r+   r+   r,   _distinct_impl   s   
rO   c              
   K   s^   t | ttjtj|| tjdtjtj|| tjdtjddd||tju r)tj	|dS tj|dS )z%See :meth:`.ColumnOperators.between`.r2   F)r   groupZgroup_contents)r   r   )
r   r   r   r   r   r%   r   r   
between_opnot_between_op)r   r&   ZcleftZcrightr0   r+   r+   r,   _between_impl   s6   rS   c                 K   s
   t | |S r5   r	   r7   r+   r+   r,   _collate_impl  s   
rT   c                 K   sJ   |d urt jtj|| tjd}t| ||f||tju rtjntjd|S )Nr2   )flagsr   )	r   r   r   r%   r   regexp_replace_opr-   regexp_match_opnot_regexp_match_op)r   r&   patternrU   r0   r+   r+   r,   _regexp_match_impl
  s&   rZ   c                 K   sN   t jtj|| tjd}|d urt jtj|| tjd}t| ||f||d|S )Nr2   )replacementrU   )r   r   r   r%   r   rV   r/   )r   r&   rY   r[   rU   r0   r+   r+   r,   _regexp_replace_impl  s(   r\   r   r   invaddmulsubdivmodtruedivZ	custom_opZjson_path_getitem_opZjson_getitem_opZ	concat_opZany_opZall_opltler   gtger   r    r!   like_opilike_opnot_like_opnot_ilike_opZcontains_opZstartswith_opZendswith_opZdesc_opZasc_opZnulls_first_opZnulls_last_opin_op	not_in_opr"   r#   r
   rK   rL   rN   rQ   rR   rI   getitemlshiftrshiftcontainsrW   rX   rV   )FN)?__doc__ r   r   r   r   elementsr   r   r   r
   r   r   r   r   r   r   r   r   NoneTyper   r-   r1   r/   r9   r;   r<   r@   r?   rF   rJ   rM   rO   rS   rT   rZ   r\   Z_create_anyZ_create_allrg   rf   r   re   rd   r   r!   r    rj   rk   rh   ri   Znot_contains_opZnot_startswith_opZnot_endswith_opZ_create_descZ_create_ascZ_create_nulls_firstZ_create_nulls_lastrm   rl   r"   r#   Zoperator_lookupr+   r+   r+   r,   <module>   s  

U
		



















 
!
"
#
$
%
&'()*+,-./01234
