U kfCA?@sXUdZddlmZddlZddlmZddlmZddlmZddlmZddlmZdd lm Z dd lm Z dd lm Z d d l m Z d dl mZd dl mZd dl mZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZddl mZdd l m Z ej!d!ed"Z"ej#rd d#lm$Z$d d$lm%Z%d d%lm&Z&dd&e'de(fdd'd(d)d*d+d,d-d.d*d/d0 d1d2Z)dnd(d3d*d,d4d*d(d5d6d7Z*d&dd8d(d)d9d,d:d*d;d5dd?d@Z,d(d)dAd*d(dBdCdDZ-d(d)dEd)d*d(dFdGdHZ.d(d)d*d*d(d>dIdJZ/d(d)d*d*dKdLdMdNZ0d(d)d*d(dOdPdQZ1d(d)d*d(dOdRdSZ2d(d)d*d(dOdTdUZ3d(d)d*d*d(d>dVdWZ4d(d)d*d(dOdXdYZ5d(d)d*d*d*d(dZd[d\Z6d]d)d^d*d]d_d`daZ7d]d)d*dbd*d(dcdddeZ8d(d)d*d*dbd*d(dfdgdhZ9e,e j:fe,e j:fe1e j:fe+e j:fe+e j:fe+e j:fe+e j:fe+e j:fe+e j:fe+e j:fe+e j:fe3e j:fe+e j:fe+e j:fe+e j:fe+e j:fe*e j:fe+e j:fe+e j:fe+e j:fe-e ;diejife)e ;djej?ife)e ;djej@ife)e ;djejAife)e ;djejBife)e ;djejCife)e ;djejDife)e ;djejEife)e ;djejFife)e ;djejGife)e ;djejHife)e ;djejIife)e ;djejJife)e ;djejKife)e ;djejLife)e ;djejMife)e ;djejNife)e ;djejOife-e ;diejPife-e ;diejQife-e ;diejRife-e ;diejSife.e ;djejTife.e ;djejUife)e ;djejVife)e ;djejWife7e j:fe4e j:fe4e j:fe5e j:fe6e j:fe6e j:fe2e j:fe/e j:fe0e j:fe0e j:fe0e j:fe8e j:fe8e j:fe9e j:fdk>ZXdleYdm<dS)oz5Default implementation of SQL comparison operations. ) annotationsN)Any)Callable)Dict)NoReturn)Optional)Tuple)Type)Union) coercions) operators)roles)type_api)and_)BinaryExpression) ClauseElement)CollationClause)CollectionAggregate)ExpressionClauseList)False_)Null)OperatorExpression)or_)True_)UnaryExpression) OperatorType)exc)util_T)bound) ColumnElement) custom_op) TypeEngineF) negate_opreverse_python_is_types result_typezColumnElement[Any]rrzOptional[OperatorType]boolzTuple[Type[Any], ...]zOptional[TypeEngine[bool]]zOperatorExpression[bool]) expropobjr%r&r'r(kwargsreturncKsl|dkrtj}t||tttfr"|tjtjfkrdt|t ttfrdt j |t tj|||||dS|tjtjfkrt j |t tj|||||dS|jrt j tj|||d}np|tjtjfkrt j |t tj|tjtj|dS|tjtjfkrt j |t tj|tjtj|dStdnt j tj|||d}|rRt j ||||||dSt j ||||||dSdS)N)type_negate modifiers)elementoperatorr*)r0r/z~Only '=', '!=', 'is_()', 'is_not()', 'is_distinct_from()', 'is_not_distinct_from()' operators can be used with None/True/False)r BOOLEANTYPE isinstancerrrr eqner)r_construct_for_opr expectrZ ConstExprRoleis_distinct_fromis_not_distinct_fromZ_is_collection_aggregateis_is_notr ArgumentErrorBinaryElementRole)r*r+r,r%r&r'r(r-r@Q/opt/hc_python/lib64/python3.8/site-packages/sqlalchemy/sql/default_comparator.py_boolean_compare3s      rBzcustom_op[Any]zOptional[TypeEngine[Any]])r*r+r,r&r(kwr.cKs<|dkr"|jr|j}n |jr"tj}t|||f||d|S)Nr&r() return_typeZ is_comparisonrr4_binary_operate)r*r+r,r&r(rCr@r@rA_custom_op_operatesrGrDzroles.BinaryElementRole[Any]zOptional[TypeEngine[_T]]zOperatorExpression[_T]c Ks^tjtj|||d}|r$||}}n ||}}|dkrJ|j||j\}}tj|||||dS)Nr*r3)r/r1)r r9rr?Z comparatorZ_adapt_expressionrr8) r*r+r,r&r(rCZ coerced_objleftrightr@r@rArFs*   rF)r*r+otherrCr.cKs2|tjkrt||S|tjkr(t||StdSN)r rrNotImplementedErrorr*r+rKrCr@r@rA_conjunction_operates     rOz2Callable[[ColumnElement[Any]], ColumnElement[Any]])r*r+fnrCr.cKs||SrLr@)r*r+rPrCr@r@rA_scalarsrQr)r*r+seq_or_selectabler%rCr.cKsDtjtj|||d}d|jkr,|jd\}}t|||fd|i|S)NrHZin_opsr%)r r9rZ InElementRoleZ _annotationsrB)r*r+rRr%rCr@r@rA_in_impls" rScKsdt|jtjs,t|jtjrPt|jjtjrPtjtj |||d}t |||f|St |||f|dS)NrH) r5typerZ INDEXABLEZ TypeDecoratorZ impl_instancer r9rr?rF_unsupported_implrNr@r@rA _getitem_impls  rVr)r*r+argrCr.cOstd|jdS)Nz1Operator '%s' is not supported on this expression)rM__name__)r*r+rWrCr@r@rArUsrU)r*r+rCr.cKst|dr|jS|SdS)z%See :meth:`.ColumnOperators.__inv__`.negation_clauseN)hasattrrYZ_negater*r+rCr@r@rA _inv_impls r\cKst|tj|jdS)z%See :meth:`.ColumnOperators.__neg__`.r3r/)rr negrTr[r@r@rA _neg_impl sr_cKst|tj|jdS)z)See :meth:`.ColumnOperators.bitwise_not`.r])rr bitwise_not_oprTr[r@r@rA_bitwise_not_impls rac KsBt|tjtjtj||tjdftj|tjkr2tj ntjd|S)z#See :meth:`.ColumnOperators.match`.rH)r(r%) rBr match_opr r9rr?rZ MATCHTYPE not_match_oprNr@r@rA _match_impls" rdcKst|tj|jdS)z&See :meth:`.ColumnOperators.distinct`.r])rr distinct_oprTr[r@r@rA_distinct_impl4s rf)r*r+cleftcrightrCr.c Ks\t|tjtjtjtjt j ||tjdtjt j ||tjddd||tj krPtj ntj |dS)z%See :meth:`.ColumnOperators.between`.rHFgroupr0r1) rr_construct_for_listr rrNULLTYPEr r9rr? between_opnot_between_op)r*r+rgrhrCr@r@rA _between_impl=s2rpzColumnElement[str]str)r*r+ collationrCr.cKs t||SrL)rZ_create_collation_expression)r*r+rrrCr@r@rA _collate_implbsrsz Optional[str])r*r+patternflagsrCr.cKs*t|tjtj||tjd|tjd|idS)NrHrurk)rr r9rr?r comma_opnot_regexp_match_op)r*r+rtrurCr@r@rA_regexp_match_implhsrx)r*r+rt replacementrurCr.c KsLt|tjtjtjtjt j ||tjdtjt j ||tjddd|d|idS)NrHFriru)r1) rrrlr rvrrmr r9rr?)r*r+rtryrurCr@r@rA_regexp_replace_impl}s,rzrPr%)>rrinvaddmulsubdivmodZbitwise_xor_opZ bitwise_or_opZbitwise_and_opr`Zbitwise_lshift_opZbitwise_rshift_optruedivfloordivr#Zjson_path_getitem_opZjson_getitem_opZ concat_opZany_opZall_opltler7gtger6r:r;like_opilike_op not_like_op not_ilike_opZ contains_opZ icontains_opZ startswith_opZistartswith_opZ endswith_opZ iendswith_opZdesc_opZasc_opZnulls_first_opZ nulls_last_opin_op not_in_opr<r=Zcollaterbrcrernror^getitemlshiftrshiftcontainsZregexp_match_oprwZregexp_replace_opzDict[str, Tuple[Callable[..., ColumnElement[Any]], util.immutabledict[str, Union[OperatorType, Callable[..., ColumnElement[Any]]]]]]operator_lookup)FN)Z__doc__ __future__rtypingrrrrrrr r r r rrelementsrrrrrrrrrrrrrrrTypeVarr TYPE_CHECKINGr"r#r$rTr)rBrGrFrOrQrSrVrUr\r_rardrfrprsrxrz EMPTY_DICTZ immutabledictZ _create_anyZ _create_allrrr6rrr7r;r:rrrrZnot_contains_opZnot_icontains_opZnot_startswith_opZnot_istartswith_opZnot_endswith_opZnot_iendswith_opZ _create_descZ _create_ascZ_create_nulls_firstZ_create_nulls_lastrrr<r=r__annotations__r@r@r@rAsN                                "b     %+