
    f3fi                       d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	m
Z
 ddlmZ e	rddlmZ  G d d	e      Zdd
Z G d de      Z G d dee      Z G d dee      Z G d dee      Z G d de      Z G d de      Z G d de      Zy)z7Internal representation of a structured query language.    )annotations)ABCabstractmethod)Enum)TYPE_CHECKINGAny)	BaseModel)Sequencec                  p    e Zd ZU dZdZded<   	 dZded<   	 ddZedd       Z	edd	       Z
edd
       Zy)Visitorz=Defines interface for IR translation using a visitor pattern.NzSequence[Comparator] | Noneallowed_comparatorszSequence[Operator] | Noneallowed_operatorsc                $   t        |t              r7| j                  +|| j                  vrd| d| j                   }t        |      t        |t              r9| j
                  ,|| j
                  vrd| d| j
                   }t        |      y y y )NzReceived disallowed operator z. Allowed comparators are zReceived disallowed comparator )
isinstanceOperatorr   
ValueError
Comparatorr   )selffuncmsgs      ]/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/langchain_core/structured_query.py_validate_funczVisitor._validate_func   s    tX&&&2D222 0v 6##'#9#9":<  S/!tZ(((4D444 2$ 8##'#;#;"<>  S/! 5 5 )    c                     y)z^Translate an Operation.

        Args:
            operation: Operation to translate.
        N )r   	operations     r   visit_operationzVisitor.visit_operation-       r   c                     y)z`Translate a Comparison.

        Args:
            comparison: Comparison to translate.
        Nr   )r   
comparisons     r   visit_comparisonzVisitor.visit_comparison5   r   r   c                     y)zpTranslate a StructuredQuery.

        Args:
            structured_query: StructuredQuery to translate.
        Nr   )r   structured_querys     r   visit_structured_queryzVisitor.visit_structured_query=   r   r   )r   zOperator | ComparatorreturnNone)r   	Operationr%   r   )r    
Comparisonr%   r   )r#   StructuredQueryr%   r   )__name__
__module____qualname____doc__r   __annotations__r   r   r   r   r!   r$   r   r   r   r   r      sd    G7;4;.3707,",      r   r   c                    d}t        |       D ]D  \  }}|j                         r|dk7  r|d|j                         z   z  }2||j                         z  }F |S )zConvert a name into snake_case. r   _)	enumerateisupperlower)name
snake_caseichars       r   _to_snake_caser9   F   sZ    JT? '4<<>a1f#

,,J$**,&J	'
 r   c                      e Zd ZdZddZy)ExprzBase class for all expressions.c                f     t        |dt        | j                  j                               |       S )zAccept a visitor.

        Args:
            visitor: visitor to accept.

        Returns:
            result of visiting.
        visit_)getattrr9   	__class__r*   )r   visitors     r   acceptzExpr.acceptT   s5     Tww&8O8O)P(Q RS
 	
r   N)r@   r   r%   r   )r*   r+   r,   r-   rA   r   r   r   r;   r;   Q   s
    )
r   r;   c                      e Zd ZdZdZdZdZy)r   zEnumerator of the operations.andornotN)r*   r+   r,   r-   ANDORNOTr   r   r   r   r   b   s    '
C	B
Cr   r   c                  8    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZy)r   z'Enumerator of the comparison operators.eqnegtgteltltecontainlikeinninN)r*   r+   r,   r-   EQNEGTGTELTLTECONTAINLIKEINNINr   r   r   r   r   j   s7    1	B	B	B
C	B
CGD	B
Cr   r   c                      e Zd ZdZy)FilterDirectivezFiltering expression.N)r*   r+   r,   r-   r   r   r   r_   r_   y   s    r   r_   c                  ^     e Zd ZU dZded<   	 ded<   	 ded<   	 	 	 	 	 	 	 	 	 	 	 d	 fdZ xZS )
r(   zComparison to a value.r   
comparatorstr	attributer   valuec                ,    t        |   d|||d| y)zCreate a Comparison.

        Args:
            comparator: The comparator to use.
            attribute: The attribute to compare.
            value: The value to compare to.
        )ra   rc   rd   Nr   super__init__)r   ra   rc   rd   kwargsr?   s        r   rh   zComparison.__init__   s&     	 	
!Ye	
GM	
r   )
ra   r   rc   rb   rd   r   ri   r   r%   r&   r*   r+   r,   r-   r.   rh   __classcell__r?   s   @r   r(   r(   }   sQ      N#J"
$
14
=@
LO
	
 
r   r(   c                  N     e Zd ZU dZded<   	 ded<   	 	 	 	 	 	 	 	 	 d fdZ xZS )r'   z(Logical operation over other directives.r   operatorlist[FilterDirective]	argumentsc                *    t        |   d||d| y)zCreate an Operation.

        Args:
            operator: The operator to use.
            arguments: The arguments to the operator.
        )rn   rp   Nr   rf   )r   rn   rp   ri   r?   s       r   rh   zOperation.__init__   s     	J(iJ6Jr   )rn   r   rp   ro   ri   r   r%   r&   rj   rl   s   @r   r'   r'      sH    2$$(
K 
K-B
KNQ
K	
K 
Kr   r'   c                  `     e Zd ZU dZded<   	 ded<   	 ded<   	 	 d		 	 	 	 	 	 	 	 	 d
 fdZ xZS )r)   zStructured query.rb   queryFilterDirective | Nonefilter
int | Nonelimitc                ,    t        |   d|||d| y)zCreate a StructuredQuery.

        Args:
            query: The query string.
            filter: The filtering expression.
            limit: The limit on the number of results.
        )rs   ru   rw   Nr   rf   )r   rs   ru   rw   ri   r?   s        r   rh   zStructuredQuery.__init__   s     	KuV5KFKr   )N)
rs   rb   ru   rt   rw   rv   ri   r   r%   r&   rj   rl   s   @r   r)   r)      sf    J"") !	LL 'L 	L
 L 
L Lr   r)   N)r5   rb   r%   rb   )r-   
__future__r   abcr   r   enumr   typingr   r   pydanticr	   collections.abcr
   r   r9   r;   rb   r   r   r_   r(   r'   r)   r   r   r   <module>r      s    = " #  % (4c 4n
9 
"sD d  dC  
 
4K K*Ld Lr   