B
    KLc                 @   sZ  d dl Z d dl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ZdZdZdZdZdZ	dd Zdd Zdd Zdd ZdzddZdd Zdd ZG dd deZG d d! d!eZG d"d# d#eZG d$d% d%eZ G d&d' d'eZ!dej"ddfd(d)Z#G d*d+ d+eZ$G d,d- d-eZ%G d.d/ d/eZ&G d0d1 d1eZ'G d2d3 d3eZ(G d4d5 d5eZ)G d6d7 d7e!eZ*G d8d9 d9e*eZ+G d:d; d;eZ,G d<d= d=e%e!eZ-G d>d? d?e%e!eZ.G d@dA dAe%eZ/G dBdC dCe$eZ0G dDdE dEe eZ1G dFdG dGe%eZ2G dHdI dIe%e!eej3Z4G dJdK dKe4eZ5G dLdM dMe4eZ6G dNdO dOe eZ7G dPdQ dQeZ8G dRdS dSeeZ9G dTdU dUee%eZ:G dVdW dWee eZ;G dXdY dYe;Z<G dZd[ d[eZ=G d\d] d]e*Z>G d^d_ d_e'e%eZ?G d`da daeZ@G dbdc dce%eZAG ddde dee$eZBG dfdg dge@ZCG dhdi dieZDG djdk dkeZEG dldm dme'e$eZFG dndo doeFZGG dpdq dqeGZHG drds dse'e$eZIG dtdu due$eZJG dvdw dwe$eZKi ZLxVeMeD ]JZNeOeeNZPeNQdxreNRdxdyZNeNeS kreS eN ePZTeTeLeP< qW dS ){    N   )	operators)roles)visitors)ExecutableOption)Options)HasCacheKey)	Visitable   )exc)
inspection)util)collections_abcc             C   s   t | ttjf ot| d S )zhReturn whether or not the element is a "literal" in the context
    of a SQL expression construct.

    __clause_element__)
isinstancer	   schemaSchemaEventTargethasattr)element r   7lib/python3.7/site-packages/sqlalchemy/sql/coercions.py_is_literal    s    r   c             C   st   t | tjr4t | ts4x| D ]}t|sdS qW dS t | ttjtt	t
jjf ort| d ort | t prt| t S )a  Return whether or not the element is a "literal" in the context
    of a SQL expression construct.

    does a deeper more esoteric check than _is_literal.   is used
    for lambda elements that have to distinguish values that would
    be bound vs. not without any context.

    FTr   )r   r   Sequencestr_deep_is_literalr	   r   r   r   r   r   ZlanghelpersZ_symbolr   type
issubclass)r   elemr   r   r   r   /   s     

r   c             C   s   t | d||f S )Nz.. warning:: The %s argument to %s can be passed as a Python string argument, which will be treated as **trusted SQL text** and rendered as given.  **DO NOT PASS UNTRUSTED INPUT TO THIS PARAMETER**.)r   Zadd_parameter_text)Z	paramnameZmeth_rstZ	param_rstr   r   r   _document_text_coercionU   s    r   c             C   sT   |rLt |d tttfrLt|dkrLt |d trDtd| |f  |d S |S d S )Nr   r   zThe "%s" argument to %s(), when referring to a sequence of items, is now passed as a series of positional elements, rather than as a list. )r   listsetdictlenr   warn_deprecated_20)ZattrnameZfnnameargsr   r   r   !_expression_collection_was_a_listc   s    $r%   Fc             K   s  | j r2t|r2t|dr2tj|| tjf ||dS t|  }|}t|tj	t
jt
jfsLd }|jrp|j|f|}n|}d}	|jrt|| rt|drd}	n,x*t|drd}	t|dds| }qP qW |	sF|jr$tj|dd}
|
d k	r$|r|
j y|
 }W n" tk
r"   ||| Y nX |d krJ|j|fd|i|}n|}n|}|d k	rr|jsr|jrr|j|_|j|jjkr|jr|j|f||d	|}|S |j||fd|i|S d S )
N__code__)apply_propagate_attrsFr   Tis_clause_element)Zraiseerrargname)r)   original_element)allows_lambdacallabler   lambdasZLambdaElementZLambdaOptions_impl_lookupr   elementsZClauseElementr   Z
SchemaItemZFetchedValue_resolve_literal_only_literal_coercion$_skip_clauseelement_for_target_matchgetattrr   _use_inspectionr   inspectZ_post_inspectAttributeError_raise_for_expectedZ_propagate_attrs_role_class	__class____mro___post_coercion_implicit_coercions)roler   r'   r)   Zpost_inspectkwimplr*   resolvedr(   Zinspr   r   r   expectp   sp    	







rA   c             K   s   d|d< t | |f|S )NTas_key)rA   )r=   r   r>   r   r   r   expect_as_key   s    rC   c             c   s|   xv|D ]n}d }d }t | |}t|tjr2| }}n$g }t|i d|ji |rV|d }|d k	rb|n|}||||fV  qW d S )Ncolumnr   )rA   r   r   string_typesr   Ztraverseappend)r=   ZexpressionsexprZstrnamerD   r@   ZcolsZadd_elementr   r   r    expect_col_expression_collection   s    


rH   c               @   s@   e Zd ZdZdd ZdZdZdZdd Zddd	Z	dd
dZ
dS )RoleImpl)r8   namer4   c             K   s
   t  d S )N)NotImplementedError)selfr   r>   r   r   r   r1      s    zRoleImpl._literal_coercionNFc             C   s    || _ |j| _t|tj| _d S )N)r8   Z
_role_namerJ   r   r   ZUsesInspectionr4   )rL   Z
role_classr   r   r   __init__   s    zRoleImpl.__init__c             K   s   |  ||| d S )N)r7   )rL   r   r@   r)   r>   r   r   r   r<      s    zRoleImpl._implicit_coercionsc       	      C   sv   |d k	r||k	rd||f }nt |}|r<d| j||f }nd| j|f }|rZ|d| 7 }tjtj||d|d d S )Nz!%r object resolved from %r objectz$%s expected for argument %r; got %s.z%s expected, got %s. )code)replace_context)reprrJ   r   raise_r   ArgumentError)	rL   r   r)   r@   advicerO   errZgotmsgr   r   r   r7     s    	
zRoleImpl._raise_for_expected)N)NNNNN)__name__
__module____qualname__	__slots__r1   r;   r0   r2   rM   r<   r7   r   r   r   r   rI      s   
    rI   c               @   s   e Zd ZdZdd ZdS )_Deannotater   c             K   s   ddl m} ||S )Nr   )_deep_deannotate)r   r\   )rL   r@   r>   r\   r   r   r   r;   !  s    z_Deannotate._post_coercionN)rW   rX   rY   rZ   r;   r   r   r   r   r[     s   r[   c               @   s   e Zd ZdZdZdS )_StringOnlyr   TN)rW   rX   rY   rZ   r0   r   r   r   r   r]   '  s   r]   c               @   s"   e Zd ZdZdddZdd ZdS )_ReturnsStringKeyr   Nc             K   s"   t |tjr|S | ||| d S )N)r   r   rE   r7   )rL   r*   r@   r)   r>   r   r   r   r<   0  s    z%_ReturnsStringKey._implicit_coercionsc             K   s   |S )Nr   )rL   r   r>   r   r   r   r1   8  s    z#_ReturnsStringKey._literal_coercion)N)rW   rX   rY   rZ   r<   r1   r   r   r   r   r^   -  s   
r^   c               @   s"   e Zd ZdZdd ZdddZdS )_ColumnCoercionsr   c             C   s   t d d S )Nz|implicitly coercing SELECT object to scalar subquery; please use the .scalar_subquery() method to produce a scalar subquery.)r   warn)rL   r   r   r   "_warn_for_scalar_subquery_coercion?  s    z3_ColumnCoercions._warn_for_scalar_subquery_coercionNc             K   sz   t |dds| ||| nZ|jr2|   | S |jrVt|tjrV|   |j	 S | j
jrh|jrh|S | ||| d S )Nr(   F)r3   r7   _is_select_statementra   scalar_subquery_is_from_clauser   
selectableZSubqueryr   r8   r+   _is_lambda_element)rL   r*   r@   r)   r>   r   r   r   r<   F  s    

z$_ColumnCoercions._implicit_coercions)N)rW   rX   rY   rZ   ra   r<   r   r   r   r   r_   <  s   r_   c             C   sB   t j|dt | |rd|f nd|r,d| ndd |d d S )Nzc%(extra)sTextual SQL expression %(expr)r %(argname)sshould be explicitly declared as text(%(expr)r)zfor argument %s z%s )rG   r)   extra)rP   )r   rR   ellipses_string)r   r)   Zexc_clsrh   rU   r   r   r   _no_text_coercionY  s    rj   c               @   s   e Zd ZdZdddZdS )_NoTextCoercionr   Nc             K   s6   t |tjr&ttj| jr&t|| n| || d S )N)	r   r   rE   r   r/   
TextClauser8   rj   r7   )rL   r   r)   r>   r   r   r   r1   m  s    z!_NoTextCoercion._literal_coercion)N)rW   rX   rY   rZ   r1   r   r   r   r   rk   j  s   rk   c               @   s0   e Zd ZdZdZdZdZdddZd	ddZdS )
_CoerceLiteralsr   FNc             C   s
   t ||S )N)rj   )rL   r   r)   r   r   r   _text_coercion|  s    z_CoerceLiterals._text_coercionc             K   s   t |tjr8| jr(|dkr(tjdddS | j||f|S | jrn|d krNt S |dkr^t	 S |dkrnt
 S | jrt |tjrtjt|ddS | || d S )N*T)Z
is_literalF)r   r   rE   _coerce_starr/   ColumnClausern   _coerce_constsNullFalse_True__coerce_numericsnumbersNumberr   r7   )rL   r   r)   r>   r   r   r   r1     s    z!_CoerceLiterals._literal_coercion)N)N)	rW   rX   rY   rZ   rr   rp   rv   rn   r1   r   r   r   r   rm   v  s   
rm   c               @   s$   e Zd ZdZdddZdddZdS )	LiteralValueImplTNc             K   s2   t |s | j|f||d| tjd ||ddS )N)r@   r)   T)type_unique)r   r7   r/   BindParameter)rL   r   r@   r)   rz   r>   r   r   r   r<     s    z$LiteralValueImpl._implicit_coercionsc             K   s   |S )Nr   )rL   r   r)   rz   r>   r   r   r   r1     s    z"LiteralValueImpl._literal_coercion)N)NN)rW   rX   rY   r0   r<   r1   r   r   r   r   ry     s   
	ry   c                   s"   e Zd ZdZd fdd	Z  ZS )_SelectIsNotFromr   Nc                s`   t |tjst |tjr6d|d k	r(|jn|f }d}nd  }}tt| j|f||||d|S )NzETo create a FROM clause from a %s object, use the .subquery() method.Z89ve)r)   r@   rT   rO   )r   r   ZSelectStatementRoler9   superr}   r7   )rL   r   r)   r@   r>   rT   rO   )r9   r   r   r7     s    

z$_SelectIsNotFrom._raise_for_expected)NN)rW   rX   rY   rZ   r7   __classcell__r   r   )r9   r   r}     s   r}   c               @   s"   e Zd ZdZdddZdd ZdS )HasCacheKeyImplr   Nc             K   s"   t |tjr|S | ||| d S )N)r   
traversalsr   r7   )rL   r*   r@   r)   r>   r   r   r   r<     s    z#HasCacheKeyImpl._implicit_coercionsc             K   s   |S )Nr   )rL   r   r>   r   r   r   r1     s    z!HasCacheKeyImpl._literal_coercion)N)rW   rX   rY   rZ   r<   r1   r   r   r   r   r     s   
r   c               @   s"   e Zd ZdZdddZdd ZdS )ExecutableOptionImplr   Nc             K   s    t |tr|S | ||| d S )N)r   r   r7   )rL   r*   r@   r)   r>   r   r   r   r<     s    
z(ExecutableOptionImpl._implicit_coercionsc             K   s   |S )Nr   )rL   r   r>   r   r   r   r1     s    z&ExecutableOptionImpl._literal_coercion)N)rW   rX   rY   rZ   r<   r1   r   r   r   r   r     s   
r   c                   s,   e Zd ZdZdddZd	 fdd	Z  ZS )
ExpressionElementImplr   NFc          
   K   sn   |d kr"|s"|d ks|j s"t S ytj|||d|dS  tjk
rh } z| j||d W d d }~X Y nX d S )NT)r{   Z_is_crud)rU   )Zshould_evaluate_noner/   rs   r|   r   rS   r7   )rL   r   rJ   rz   r)   Zis_crudr>   rU   r   r   r   r1     s    z'ExpressionElementImpl._literal_coercionc                s6   t |tjrd}nd }tt| j|f|||d|S )Nz`To create a column expression from a FROM clause row as a whole, use the .table_valued() method.)r)   r@   rT   )r   r   ZAnonymizedFromClauseRoler~   r   r7   )rL   r   r)   r@   r>   rT   )r9   r   r   r7     s
    
z)ExpressionElementImpl._raise_for_expected)NNNF)NN)rW   rX   rY   rZ   r1   r7   r   r   r   )r9   r   r     s   
r   c               @   s$   e Zd ZdZdddZdddZdS )	BinaryElementImplr   Nc          
   K   sH   y|j |||dS  tjk
rB } z| j||d W d d }~X Y nX d S )N)rz   )rU   )_bind_paramr   rS   r7   )rL   r   rG   operatorbindparam_typer)   r>   rU   r   r   r   r1     s    z#BinaryElementImpl._literal_coercionc             K   s,   |j jr(|j js(||d k	r |n|j }|S )N)r   Z_isnullZ_with_binary_element_type)rL   r@   rG   r   r>   r   r   r   r;     s    z BinaryElementImpl._post_coercion)NN)N)rW   rX   rY   rZ   r1   r;   r   r   r   r   r     s   
r   c               @   s2   e Zd ZdZdddZdd Zdd Zd	d
 ZdS )InElementImplr   Nc             K   sd   |j rRt|tjr4|jjr4| | | j|jf|S | | | j| f|S n| 	||| d S )N)
rd   r   re   Aliasr   rb   _warn_for_implicit_coercionr;   selectr7   )rL   r*   r@   r)   r>   r   r   r   r<     s    

z!InElementImpl._implicit_coercionsc             C   s   t d|jj  d S )Nz_Coercing %s object into a select() for use in IN(); please pass a select() construct explicitly)r   r`   r9   rW   )rL   r   r   r   r   r   *  s    z)InElementImpl._warn_for_implicit_coercionc                s   t |tjrt |tjsi t|}xN|D ]F}t|s\t |tjsR| j	|f| qp||< q*|d kr*t
 |< q*W rt
j fdd|D  S  j|ddS n| j	|f| d S )Nc                s(   g | ] }|kr| n
  |qS r   )r   ).0o)rG   non_literal_expressionsr   r   r   
<listcomp>C  s   z3InElementImpl._literal_coercion.<locals>.<listcomp>T)	expanding)r   r   Iterabler   rE   r   r   r   ZColumnOperatorsr7   r/   rs   
ClauseListr   )rL   r   rG   r   r>   r   r   )rG   r   r   r   r1   1  s"    



zInElementImpl._literal_coercionc             K   sh   |j r| S t|tjr8t|jdkr,t|j|dS t|tj	r`|j
dd}d|_||_|S |S d S )Nr   )ZagainstT)Zmaintain_key)rb   rc   r   r/   r   r"   ZclausesAssertionErrorZ
self_groupr|   Z_cloner   Z	expand_op)rL   r   rG   r   r>   r   r   r   r;   O  s    zInElementImpl._post_coercion)N)rW   rX   rY   rZ   r<   r   r1   r;   r   r   r   r   r     s
   
r   c                   s>   e Zd ZdZdZd fdd	Zd fdd	Zdd	d
Z  ZS )OnClauseImplr   TNFc                s6   |rt |tr|S tt| j||f||d|S d S )N)r)   legacy)r   r   r~   r   r<   )rL   r*   r@   r)   r   r>   )r9   r   r   r<   g  s    
z OnClauseImpl._implicit_coercionsc                s.   |rt |trtd |S tt| ||S )NzUsing strings to indicate relationship names in Query.join() is deprecated and will be removed in SQLAlchemy 2.0.  Please use the class-bound attribute directly.)r   r   r   r#   r~   r   rn   )rL   r   r)   r   )r9   r   r   rn   u  s
    zOnClauseImpl._text_coercionc             K   s   t |tjr|S |S )N)r   r   JoinTargetRole)rL   r@   r*   r>   r   r   r   r;     s    zOnClauseImpl._post_coercion)NF)NF)N)	rW   rX   rY   rZ   rr   r<   rn   r;   r   r   r   )r9   r   r   b  s
   r   c               @   s   e Zd ZdZdZdddZdS )WhereHavingImplr   TNc             C   s
   t ||S )N)rj   )rL   r   r)   r   r   r   rn     s    zWhereHavingImpl._text_coercion)N)rW   rX   rY   rZ   rr   rn   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdZdddZdS )StatementOptionImplr   TNc             C   s
   t |S )N)r/   rl   )rL   r   r)   r   r   r   rn     s    z"StatementOptionImpl._text_coercion)N)rW   rX   rY   rZ   rr   rn   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdS )ColumnArgumentImplr   N)rW   rX   rY   rZ   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdS )ColumnArgumentOrKeyImplr   N)rW   rX   rY   rZ   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdddZdS )StrAsPlainColumnImplr   Nc             C   s
   t |S )N)r/   rq   )rL   r   r)   r   r   r   rn     s    z#StrAsPlainColumnImpl._text_coercion)N)rW   rX   rY   rZ   rn   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdZdddZdS )ByOfImplr   TNc             C   s
   t |S )N)r/   Z_textual_label_reference)rL   r   r)   r   r   r   rn     s    zByOfImpl._text_coercion)N)rW   rX   rY   rZ   rr   rn   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdd ZdS )OrderByImplr   c             K   s(   t || jr |jd k	r t|S |S d S )N)r   r8   Z_order_by_label_elementr/   Z_label_reference)rL   r@   r>   r   r   r   r;     s    

zOrderByImpl._post_coercionN)rW   rX   rY   rZ   r;   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdddZdS )GroupByImplr   Nc             K   s    t |tjrtj|j S |S d S )N)r   r   ZStrictFromClauseRoler/   r   c)rL   r*   r@   r)   r>   r   r   r   r<     s    zGroupByImpl._implicit_coercions)N)rW   rX   rY   rZ   r<   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdddZdS )DMLColumnImplr   Fc             K   s   |r
|j S |S d S )N)key)rL   r   rB   r>   r   r   r   r;     s    zDMLColumnImpl._post_coercionN)F)rW   rX   rY   rZ   r;   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdddZdS )ConstExprImplr   Nc             K   s@   |d krt  S |dkr t  S |dkr0t  S | || d S )NFT)r/   rs   rt   ru   r7   )rL   r   r)   r>   r   r   r   r1     s    zConstExprImpl._literal_coercion)N)rW   rX   rY   rZ   r1   r   r   r   r   r     s   r   c               @   s$   e Zd ZdZdddZdddZdS )	TruncatedLabelImplr   Nc             K   s"   t |tjr|S | ||| d S )N)r   r   rE   r7   )rL   r*   r@   r)   r>   r   r   r   r<     s    z&TruncatedLabelImpl._implicit_coercionsc             K   s   t |tjr|S t|S dS )zcoerce the given value to :class:`._truncated_label`.

        Existing :class:`._truncated_label` and
        :class:`._anonymous_label` objects are passed
        unchanged.
        N)r   r/   Z_truncated_label)rL   r   r)   r>   r   r   r   r1     s    z$TruncatedLabelImpl._literal_coercion)N)N)rW   rX   rY   rZ   r<   r1   r   r   r   r   r     s   
r   c               @   s   e Zd ZdZdZdddZdS )DDLExpressionImplr   TNc             C   s
   t |S )N)r/   rl   )rL   r   r)   r   r   r   rn     s    z DDLExpressionImpl._text_coercion)N)rW   rX   rY   rZ   rr   rn   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdS )DDLConstraintColumnImplr   N)rW   rX   rY   rZ   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdS )DDLReferredColumnImplr   N)rW   rX   rY   rZ   r   r   r   r   r     s   r   c               @   s"   e Zd ZdZdddZdd ZdS )LimitOffsetImplr   Nc             K   s   |d krd S |  ||| d S )N)r7   )rL   r   r@   r)   r>   r   r   r   r<     s    z#LimitOffsetImpl._implicit_coercionsc             K   s,   |d krd S t |}tj|||ddS d S )NT)rz   r{   )r   Zasintre   Z_OffsetLimitParam)rL   r   rJ   rz   r>   valuer   r   r   r1      s
    
z!LimitOffsetImpl._literal_coercion)N)rW   rX   rY   rZ   r<   r1   r   r   r   r   r     s   
r   c                   s"   e Zd ZdZd fdd	Z  ZS )LabeledColumnExprImplr   Nc                s\   t |tjr|d S tt| j||fd|i|}t |tjrJ|d S | ||| d S )Nr)   )r   r   ZExpressionElementRoleZlabelr~   r   r<   r7   )rL   r*   r@   r)   r>   new)r9   r   r   r<   -  s    


z)LabeledColumnExprImpl._implicit_coercions)N)rW   rX   rY   rZ   r<   r   r   r   )r9   r   r   *  s   r   c               @   s4   e Zd ZdZdZdZdZedej	Z
dddZdS )ColumnsClauseImplr   Tz^\w\S*$Nc             C   sL   t |}| j| }tdt||r2d|f nd|r<dndd d S )NzTextual column expression %(column)r %(argname)sshould be explicitly declared with text(%(column)r), or use %(literal_column)s(%(column)r) for more specificityzfor argument %srg   literal_columnrD   )rD   r)   r   )r   _guess_straight_columnmatchr   rS   r   ri   )rL   r   r)   Zguess_is_literalr   r   r   rn   E  s    z ColumnsClauseImpl._text_coercion)N)rW   rX   rY   rZ   rr   rv   rp   recompileIr   rn   r   r   r   r   r   <  s   r   c               @   s   e Zd ZdZdS )ReturnsRowsImplr   N)rW   rX   rY   rZ   r   r   r   r   r   X  s   r   c                   s6   e Zd ZdZd	ddZd
 fdd	ZdddZ  ZS )StatementImplr   Nc             K   sH   ||k	rDt |tjsDy
|j W n$ tk
rB   td| d Y nX |S )Na  Object %r should not be used directly in a SQL statement context, such as passing to methods such as session.execute().  This usage will be disallowed in a future release.  Please use Core select() / update() / delete() etc. with Session.execute() and other statement execution methods.z1.4)r   r   rE   Z_execute_on_connectionr6   warn_deprecated)rL   r@   r*   r)   r>   r   r   r   r;   _  s    


zStatementImpl._post_coercionc                s,   |j r
|S tt| j||fd|i|S d S )Nr)   )rf   r~   r   r<   )rL   r*   r@   r)   r>   )r9   r   r   r<   u  s    
z!StatementImpl._implicit_coercionsc             C   s   t d t|S )NzUsing plain strings to indicate SQL statements without using the text() construct is  deprecated and will be removed in version 2.0.  Ensure plain SQL statements are passed using the text() construct.)r   r#   r/   rl   )rL   r   r)   r   r   r   rn     s    zStatementImpl._text_coercion)N)N)N)rW   rX   rY   rZ   r;   r<   rn   r   r   r   )r9   r   r   \  s   
	r   c               @   s   e Zd ZdZdddZdS )SelectStatementImplr   Nc             K   s    |j r| S | ||| d S )N)_is_text_clausecolumnsr7   )rL   r*   r@   r)   r>   r   r   r   r<     s    z'SelectStatementImpl._implicit_coercions)N)rW   rX   rY   rZ   r<   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdS )
HasCTEImplr   N)rW   rX   rY   rZ   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdS )	IsCTEImplr   N)rW   rX   rY   rZ   r   r   r   r   r     s   r   c               @   s(   e Zd ZdZdZd	ddZd
ddZdS )JoinTargetImplr   TFc             K   s   t |tr|S d S )N)r   r   )rL   r   r   r>   r   r   r   r1     s    
z JoinTargetImpl._literal_coercionNc             K   sn   t |tjr|S |r,t |tr,td |S |r@t |tjr@|S |r\|jr\tjddd |S | 	||| d S )NzUsing strings to indicate relationship names in Query.join() is deprecated and will be removed in SQLAlchemy 2.0.  Please use the class-bound attribute directly.zImplicit coercion of SELECT and textual SELECT constructs into FROM clauses is deprecated; please call .subquery() on any Core select or ORM Query object in order to produce a subquery object.z1.4)version)
r   r   r   r   r   r#   ZWhereHavingRolerb   r   r7   )rL   r*   r@   r)   r   r>   r   r   r   r<     s    
z"JoinTargetImpl._implicit_coercions)F)NF)rW   rX   rY   rZ   r2   r1   r<   r   r   r   r   r     s   
r   c               @   s$   e Zd ZdZd	ddZd
ddZdS )FromClauseImplr   NFTc             K   sH   |j r,|r| S |rDtjddd |jS n|jr6|S | ||| d S )NzImplicit coercion of SELECT and textual SELECT constructs into FROM clauses is deprecated; please call .subquery() on any Core select or ORM Query object in order to produce a subquery object.z1.4)r   )rb   Zsubqueryr   r   _implicit_subqueryr   r7   )rL   r*   r@   r)   Zexplicit_subqueryallow_selectr>   r   r   r   r<     s    	z"FromClauseImpl._implicit_coercionsc             K   s   |r|  S |S d S )N)Z_deannotate)rL   r   Z
deannotater>   r   r   r   r;     s    zFromClauseImpl._post_coercion)NFT)F)rW   rX   rY   rZ   r<   r;   r   r   r   r   r     s
     
r   c               @   s   e Zd ZdZdddZdS )StrictFromClauseImplr   NFc             K   s0   |j r|rtjddd |jS | ||| d S )NzImplicit coercion of SELECT and textual SELECT constructs into FROM clauses is deprecated; please call .subquery() on any Core select or ORM Query object in order to produce a subquery object.z1.4)r   )rb   r   r   r   r7   )rL   r*   r@   r)   r   r>   r   r   r   r<     s    
z(StrictFromClauseImpl._implicit_coercions)NF)rW   rX   rY   rZ   r<   r   r   r   r   r     s    r   c               @   s   e Zd ZdZdddZdS )AnonymizedFromClauseImplr   FNc             K   s   |d kst |j|dS )N)flat)r   Z_anonymous_fromclause)rL   r   r   rJ   r>   r   r   r   r;     s    z'AnonymizedFromClauseImpl._post_coercion)FN)rW   rX   rY   rZ   r;   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdd ZdS )DMLTableImplr   c             K   s   d|j kr|j d S |S d S )NZ	dml_table)Z_annotations)rL   r   r>   r   r   r   r;     s    

zDMLTableImpl._post_coercionN)rW   rX   rY   rZ   r;   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdddZdS )DMLSelectImplr   Nc             K   s<   |j r*t|tjr |jjr |jS | S n| ||| d S )N)rd   r   re   r   r   rb   r   r7   )rL   r*   r@   r)   r>   r   r   r   r<     s    
z!DMLSelectImpl._implicit_coercions)N)rW   rX   rY   rZ   r<   r   r   r   r   r     s   r   c                   s"   e Zd ZdZd fdd	Z  ZS )CompoundElementImplr   Nc                sB   t |tjr|jrd}q"d}nd }tt| j|f|||d|S )NzFUse the plain select() object without calling .subquery() or .alias().z9To SELECT from any FROM clause, use the .select() method.)r)   r@   rT   )r   r   ZFromClauseRoleZ_is_subqueryr~   r   r7   )rL   r   r)   r@   r>   rT   )r9   r   r   r7   -  s    
z'CompoundElementImpl._raise_for_expected)NN)rW   rX   rY   rZ   r7   r   r   r   )r9   r   r   *  s   r   ZRoleZImpl)NNF)Urw   r   rg   r   r   r   baser   r   r   r   r	   r   r   r   r   r/   r-   r   re   Zsqltypesr   r   r   r%   rA   rC   rH   objectrI   r[   r]   r^   r_   rS   rj   rk   rm   ry   r}   r   r   r   r   r   r   r   r   r   r   r   ZByOfRoler   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r.   dirrJ   r3   clsendswithreplaceglobalsr?   r   r   r   r   <module>   s   &  
d/	&K*		

-,$	

