U
    ÌZjª+  ã                5   @   s˜  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d6dd„Zd7d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$efefefefefefefefefefefefefeej%feej&feej'feej(feej)feej*feej+feej,feej-feej.feej/feej0feej1feej2feej3feej4feej5feej6feej7feej8feej9feej:feej;feej<feej=fe"fefefe fe!fe!fefefefefefe#fe#fe$fd5œ4Z>dS )8z5Default implementation of SQL comparison operations.
é   )Ú	coercions)Ú	operators)Úroles)Útype_api)Úand_)ÚBinaryExpression)Ú
ClauseList©Úcollate)ÚCollectionAggregate)ÚFalse_)ÚNull)Úor_)ÚTrue_)ÚUnaryExpressioné   )Úexc)ÚutilNFc           	      K   s^  |d krt j}t||tttf ƒ�r|tjtjfkrbt|t	ttfƒrbt
| t tj|¡||||d�S |tjtjfkr�t
| t tj|¡||||d�S |rªtjtj||| d�}nl|tjtjfkrÚt
| t tj|¡tjtj|d�S |tjtjfk�rt
| t tj|¡tjtj|d�S t d¡‚ntjtj||| d�}|�rFt
|| ||||d�S t
| |||||d�S 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+   úd/var/www/html/TRUCKING_PROJECT/venv/lib/python3.8/site-packages/sqlalchemy/sql/default_comparator.pyÚ_boolean_compare   s˜     ÿúþú   ÿûûÿ   ÿ     ÿ     ÿr-   c                 K   s<   |d k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 krJ|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   s2   |t jkrt| |ƒS |t jkr(t| |ƒS tƒ ‚d S ©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k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   sd   t | jtjƒs,t | jtjƒrPt | jjtjƒrPtjtj	|| |d�}t
| ||f|ŽS t| ||f|Ž 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 ƒ‚d S )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 dS )z%See :meth:`.ColumnOperators.__inv__`.Únegation_clauseN)ÚhasattrrC   Z_negate©r   r&   r0   r+   r+   r,   Ú	_inv_impl¾   s    
rF   c                 K   s   t | tj| jd�S )z%See :meth:`.ColumnOperators.__neg__`.©r   r   )r   r   Únegr=   rE   r+   r+   r,   Ú	_neg_implÉ   s    rI   c              	   K   sB   t | tjtjtj|| tjd�ftj|tjkr2t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"    üý	ÿôórL   c                 K   s   t | tj| jd�S )z&See :meth:`.ColumnOperators.distinct`.rG   )r   r   Údistinct_opr=   rE   r+   r+   r,   Ú_distinct_implâ   s
      ÿrN   c              
   K   sX   t | ttjtj|| tjd�tjtj|| tjd�tjddd�||tjkrLtj	n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é   s2    üüñÿérR   c                 K   s
   t | |ƒS r5   r	   r7   r+   r+   r,   Ú_collate_impl  s    rS   c                 K   sJ   |d k	rt jtj|| tjd�}t| ||f||tjk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&   ÚpatternrT   r0   r+   r+   r,   Ú_regexp_match_impl
  s&    üýÿùørY   c                 K   sN   t jtj|| tjd�}|d k	r4t jtj|| tjd�}t| ||f||dœ|—ŽS )Nr2   )ÚreplacementrT   )r   r   r   r%   r   rU   r/   )r   r&   rX   rZ   rT   r0   r+   r+   r,   Ú_regexp_replace_impl  s.    üü  ÿ ÿÿr[   )4r   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
   rJ   rK   rM   rP   rQ   rH   ÚgetitemÚlshiftÚrshiftÚcontainsrV   rW   rU   )FN)FN)?Ú__doc__Ú r   r   r   r   Úelementsr   r   r   r
   r   r   r   r   r   r   r   r   ZNoneTyper   r-   r1   r/   r9   r;   r<   r@   r?   rF   rI   rL   rN   rR   rS   rY   r[   Z_create_anyZ_create_allrf   re   r   rd   rc   r   r!   r    ri   rj   rg   rh   Znot_contains_opZnot_startswith_opZnot_endswith_opZ_create_descZ_create_ascZ_create_nulls_firstZ_create_nulls_lastrl   rk   r"   r#   Zoperator_lookupr+   r+   r+   r,   Ú<module>   s´   ø
U

	Ì