관리-도구
편집 파일: operators.cpython-311.pyc
� �܋f@� � � � d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd lm Z dd lm Z ddlmZ ddlmZ dd lm Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ej rddlmZ neZ G d� de� � Z G d� de� � Z G d� de� � ZeeeehZeeeeee hZd� Zd� Z d � Z!e d!� � � Z"d"� Z#d#� Z$d$� Z%d%� Z&e d&� � � Z'e d'� � � Z(e d(� � � Z)e d)� � � Z*d*� Z+d+� Z,e dcd-�� � Z-e dcd.�� � Z.e dcd/�� � Z/e dcd0�� � Z0e ddd2�� � Z1e ddd3�� � Z2e d4� � � Z3e d5� � � Z4d6� Z5d7� Z6d8� Z7d9� Z8e ded:�� � Z9e ded;�� � Z:e ded<�� � Z;e ded=�� � Z<e ded>�� � Z=e ded?�� � Z>e d@� � � Z?e dA� � � Z@dB� ZAe dC� � � ZBe dD� � � ZCdE� ZDdF� ZEdG� ZFdH� ZGdI� ZHdJ� ZIdK� ZJdL� ZKdM� ZLdN� ZMdO� ZNdP� ZOe e%e&eefZPdQ� ZQeeee eee eiZRdR� ZSe�T eEeeg� � �U eeg� � ZVeV�T eeJeKg� � ZW ejX dSdT�U� � ZY ejX dVdW�U� � ZZ ejX dXdY�U� � Z[i e!dZ�e"dZ�e6dZ�e7dZ�edZ�eJdZ�eKdZ�ed[�ed[�ed[�e d[�ed[�ed\�ed\�eEd]�eDd]�e?d^�i e@d^�e/d^�e0d^�e-d^�e.d^�e3d^�e4d^�e)d^�e*d^�ed^�ed^�e'd^�e(d^�eBd^�eCd^�ed^�ed^��i ed^�e d^�e1d^�e2d^�e5d^�e d^�e%d^�e&d^�ed_�ed�eAd`�eFd_�eGd_�e+da�e#d`�e$d�eYdT��eZeZe[e[i�Z\db� Z]d,S )fz*Defines operators used in SQL expressions.� )�add)�and_)�contains)�eq)�ge)�getitem)�gt)�inv)�le)�lshift)�lt)�mod)�mul)�ne)�neg)�or_)�rshift)�sub)�truediv� )�util)�divc �F � e Zd ZdZdZd� Zd� Zd� Z d d �Zdd �Z d� Z d� ZdS )� Operatorsa� Base of comparison and logical operators. Implements base methods :meth:`~sqlalchemy.sql.operators.Operators.operate` and :meth:`~sqlalchemy.sql.operators.Operators.reverse_operate`, as well as :meth:`~sqlalchemy.sql.operators.Operators.__and__`, :meth:`~sqlalchemy.sql.operators.Operators.__or__`, :meth:`~sqlalchemy.sql.operators.Operators.__invert__`. Usually is used via its most common subclass :class:`.ColumnOperators`. � c �8 � | � t |� � S )a- Implement the ``&`` operator. When used with SQL expressions, results in an AND operation, equivalent to :func:`_expression.and_`, that is:: a & b is equivalent to:: from sqlalchemy import and_ and_(a, b) Care should be taken when using ``&`` regarding operator precedence; the ``&`` operator has the highest precedence. The operands should be enclosed in parenthesis if they contain further sub expressions:: (a == 2) & (b == 4) )�operater ��self�others �O/opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/sql/operators.py�__and__zOperators.__and__; s � �, �|�|�D�%�(�(�(� c �8 � | � t |� � S )a) Implement the ``|`` operator. When used with SQL expressions, results in an OR operation, equivalent to :func:`_expression.or_`, that is:: a | b is equivalent to:: from sqlalchemy import or_ or_(a, b) Care should be taken when using ``|`` regarding operator precedence; the ``|`` operator has the highest precedence. The operands should be enclosed in parenthesis if they contain further sub expressions:: (a == 2) | (b == 4) )r r r s r! �__or__zOperators.__or__S s � �, �|�|�C��'�'�'r# c �6 � | � t � � S )a Implement the ``~`` operator. When used with SQL expressions, results in a NOT operation, equivalent to :func:`_expression.not_`, that is:: ~a is equivalent to:: from sqlalchemy import not_ not_(a) )r r �r s r! � __invert__zOperators.__invert__k s � � �|�|�C� � � r# r FNc �: � �� t ||||� � ��� fd�}|S )a! Produce a generic operator function. e.g.:: somecolumn.op("*")(5) produces:: somecolumn * 5 This function can also be used to make bitwise operators explicit. For example:: somecolumn.op('&')(0xff) is a bitwise AND of the value in ``somecolumn``. :param operator: a string which will be output as the infix operator between this element and the expression passed to the generated function. :param precedence: precedence to apply to the operator, when parenthesizing expressions. A lower number will cause the expression to be parenthesized when applied against another operator with higher precedence. The default value of ``0`` is lower than all operators except for the comma (``,``) and ``AS`` operators. A value of 100 will be higher or equal to all operators, and -100 will be lower than or equal to all operators. :param is_comparison: if True, the operator will be considered as a "comparison" operator, that is which evaluates to a boolean true/false value, like ``==``, ``>``, etc. This flag should be set so that ORM relationships can establish that the operator is a comparison operator when used in a custom join condition. .. versionadded:: 0.9.2 - added the :paramref:`.Operators.op.is_comparison` flag. :param return_type: a :class:`.TypeEngine` class or object that will force the return type of an expression produced by this operator to be of that type. By default, operators that specify :paramref:`.Operators.op.is_comparison` will resolve to :class:`.Boolean`, and those that do not will be of the same type as the left-hand operand. .. versionadded:: 1.2.0b3 - added the :paramref:`.Operators.op.return_type` argument. .. seealso:: :ref:`types_operators` :ref:`relationship_custom_operator` c � �� ��| � � S �Nr )r �operatorr s ��r! �againstzOperators.op.<locals>.against� s �� ��8�D�%�(�(�(r# )� custom_op)r �opstring� precedence� is_comparison�return_typer- r, s ` @r! �opzOperators.op| s? ��� �t �X�z�=�+�N�N�� )� )� )� )� )� )� �r# c �2 � | � ||d�� � S )a+ Return a custom boolean operator. This method is shorthand for calling :meth:`.Operators.op` and passing the :paramref:`.Operators.op.is_comparison` flag with True. .. versionadded:: 1.2.0b3 .. seealso:: :meth:`.Operators.op` T)r0 r1 �r3 )r r/ r0 s r! �bool_opzOperators.bool_op� s � � �w�w�x�J�d�w�K�K�Kr# c �: � t t |� � � � �)a3 Operate on an argument. This is the lowest level of operation, raises :class:`NotImplementedError` by default. Overriding this on a subclass can allow common behavior to be applied to all operations. For example, overriding :class:`.ColumnOperators` to apply ``func.lower()`` to the left and right side:: class MyComparator(ColumnOperators): def operate(self, op, other): return op(func.lower(self), func.lower(other)) :param op: Operator callable. :param \*other: the 'other' side of the operation. Will be a single scalar for most operations. :param \**kwargs: modifiers. These may be passed by special operators such as :meth:`ColumnOperators.contains`. ��NotImplementedError�str�r r3 r �kwargss r! r zOperators.operate� s � �0 "�#�b�'�'�*�*�*r# c �: � t t |� � � � �)zXReverse operate on an argument. Usage is the same as :meth:`operate`. r8 r; s r! �reverse_operatezOperators.reverse_operate� s � � "�#�b�'�'�*�*�*r# )r FN)r )�__name__� __module__�__qualname__�__doc__� __slots__r"