o
    h;$                     @  s  U 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lmZ d dlmZ ddlmZ ddlmZ erd dlmZ d dlmZ d dlmZ eeef ZededZi Z de!d< G dd deZ"G dd  d ee Z#G d!d" d"e#e Z$G d#d$ d$e#e Z%G d%d& d&e#e Z&d3d*d+Z'd4d-d.Z(d5d0d1Z)d2S )6    )annotations)Any)ClassVar)Dict)Generic)
NamedTuple)Optional)Sequence)Tuple)Type)TYPE_CHECKING)TypeVar)Union)
Constraint)ForeignKeyConstraint)Index)UniqueConstraint)	TypeGuard   )util)sqla_compat)Literal)AutogenContext)DefaultImpl_C)boundz Dict[str, Type[_constraint_sig]]_clsregc                   @  sr   e Zd ZU ded< ded< edddZedd	d
ZedddZedddZ	edddZ
edddZdS )ComparisonResultz%Literal['equal', 'different', 'skip']statusstrmessagereturnboolc                 C  
   | j dkS )Nequalr   self r(   h/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/alembic/ddl/_autogen.pyis_equal-      
zComparisonResult.is_equalc                 C  r#   )N	differentr%   r&   r(   r(   r)   is_different1   r+   zComparisonResult.is_differentc                 C  r#   )Nskipr%   r&   r(   r(   r)   is_skip5   r+   zComparisonResult.is_skipc                 C  s
   | ddS )zthe constraints are equal.r$   zThe two constraints are equalr(   clsr(   r(   r)   Equal9   s   
zComparisonResult.EqualreasonUnion[str, Sequence[str]]c                 C     | dd t|S )z9the constraints are different for the provided reason(s).r,   , joinr   to_listr1   r3   r(   r(   r)   	Different>   s   zComparisonResult.Differentc                 C  r5   )zthe constraint cannot be compared for the provided reason(s).

        The message is logged, but the constraints will be otherwise
        considered equal, meaning that no migration command will be
        generated.
        r.   r6   r7   r:   r(   r(   r)   SkipC   s   zComparisonResult.SkipNr!   r"   )r!   r   )r3   r4   r!   r   )__name__
__module____qualname____annotations__propertyr*   r-   r/   classmethodr2   r;   r<   r(   r(   r(   r)   r   )   s   
 r   c                   @  s  e Zd ZU ded< ded< ded< ded< d	Zd
ed< d	Zd
ed< d	Zd
ed< ded< d9ddZedd Z	d:ddZ
d;ddZd<dd Zed=d"d#Zd>d'd(Zejd)d* Zejd?d+d,Zejd?d-d.Zejd?d/d0Zd@d1d2Zd@d3d4ZdAd6d7Zd8S )B_constraint_sigr   constTuple[Any, ...]_sigz,Optional[sqla_compat._ConstraintNameDefined]namer   implFzClassVar[bool]	_is_index_is_fk_is_uqr"   _is_metadatar!   Nonec                 C  s   |    d S N)	_registerr0   r(   r(   r)   __init_subclass__\      z!_constraint_sig.__init_subclass__c                 C     t  rO   NotImplementedErrorr0   r(   r(   r)   rP   _      z_constraint_sig._registeris_metadatac                 C  rS   rO   rT   r'   rW   rI   rE   r(   r(   r)   __init__c      z_constraint_sig.__init__other_constraint_sig[Any]r   c                 C  s.   | j |j u sJ | jsJ |jrJ | |S rO   )rI   rM   _compare_to_reflectedr'   r[   r(   r(   r)   compare_to_reflectedh   s   


z$_constraint_sig.compare_to_reflected_constraint_sig[_C]c                 C  rS   rO   rT   r^   r(   r(   r)   r]   q   rZ   z%_constraint_sig._compare_to_reflected
constraintc                 C  s   t |j |||}|S rO   )r   __visit_name__)r1   rW   rI   ra   sigr(   r(   r)   from_constraintv   s   z_constraint_sig.from_constraintcontextr   Optional[str]c                 C  s   t | j|jS rO   )r   _get_constraint_final_namerE   dialect)r'   re   r(   r(   r)   md_name_to_sql_name   s   z#_constraint_sig.md_name_to_sql_namec                 C  s   t | j| jjS rO   )r   _constraint_is_namedrE   rI   rh   r&   r(   r(   r)   is_named   s   z_constraint_sig.is_namedc                 C     | j S rO   )rG   r&   r(   r(   r)   unnamed   rV   z_constraint_sig.unnamedc                 C  rS   rO   rT   r&   r(   r(   r)   unnamed_no_options   rV   z"_constraint_sig.unnamed_no_optionsc                 C     | j f| j S rO   )rH   rm   r&   r(   r(   r)   	_full_sig      z_constraint_sig._full_sigc                 C  s   | j |j kS rO   rp   r^   r(   r(   r)   __eq__   rR   z_constraint_sig.__eq__c                 C  s   | j |j kS rO   rr   r^   r(   r(   r)   __ne__   rR   z_constraint_sig.__ne__intc                 C  s
   t | jS rO   )hashrp   r&   r(   r(   r)   __hash__   s   
z_constraint_sig.__hash__Nr!   rN   )rW   r"   rI   r   rE   r   r!   rN   )r[   r\   r!   r   r[   r`   r!   r   )rW   r"   rI   r   ra   r   r!   r`   )re   r   r!   rf   )r!   rF   r=   )r!   ru   )r>   r?   r@   rA   rJ   rK   rL   rQ   rC   rP   rY   r_   r]   rd   ri   r   memoized_propertyrk   rm   rn   rp   rs   rt   rw   r(   r(   r(   r)   rD   N   s:   
 




	




rD   c                   @  sD   e Zd ZdZedddZdZdddZedddZ	dddZ
dS )_uq_constraint_sigTr!   rN   c                 C     | t d< d S )Nunique_constraintr   r0   r(   r(   r)   rP         z_uq_constraint_sig._registerrW   r"   rI   r   rE   r   c                 C  s>   || _ || _t|j| _ttdd |jD | _|| _	d S )Nc                 S     g | ]}|j qS r(   rH   .0colr(   r(   r)   
<listcomp>       z/_uq_constraint_sig.__init__.<locals>.<listcomp>)
rI   rE   r   constraint_name_or_nonerH   tuplesortedcolumnsrG   rM   rX   r(   r(   r)   rY      s
   
z_uq_constraint_sig.__init__Tuple[str, ...]c                 C     t dd | jjD S )Nc                 S  r   r(   r   r   r(   r(   r)   r      r   z3_uq_constraint_sig.column_names.<locals>.<listcomp>r   rE   r   r&   r(   r(   r)   column_names      z_uq_constraint_sig.column_namesr[   r`   r   c                 C  0   | j sJ | }|}t|sJ | j|j|jS rO   )rM   	is_uq_sigrI   compare_unique_constraintrE   r'   r[   metadata_objconn_objr(   r(   r)   r]      s   
z(_uq_constraint_sig._compare_to_reflectedNrx   )rW   r"   rI   r   rE   r   r!   rN   r!   r   ry   )r>   r?   r@   rL   rC   rP   	is_uniquerY   rB   r   r]   r(   r(   r(   r)   r{      s    
r{   c                   @  s   e Zd ZU dZded< ed"ddZd#ddZd$ddZe	j
dd Ze	j
d%ddZe	j
d&ddZe	j
dd Ze	j
dd  Zd!S )'_ix_constraint_sigTzsqla_compat._ConstraintNamerH   r!   rN   c                 C  r|   )Nindexr~   r0   r(   r(   r)   rP      r   z_ix_constraint_sig._registerrW   r"   rI   r   rE   r   c                 C  s*   || _ || _|j| _t|j| _|| _d S rO   )rI   rE   rH   r"   uniquer   rM   rX   r(   r(   r)   rY      s
   
z_ix_constraint_sig.__init__r[   r`   r   c                 C  r   rO   )rM   is_index_sigrI   compare_indexesrE   r   r(   r(   r)   r]      s
   
z(_ix_constraint_sig._compare_to_reflectedc                 C  s   t | jS rO   )r   is_expression_indexrE   r&   r(   r(   r)   has_expressions   r   z"_ix_constraint_sig.has_expressionsr   c                 C  r   )Nc                 S  r   r(   r   r   r(   r(   r)   r      r   z3_ix_constraint_sig.column_names.<locals>.<listcomp>r   r&   r(   r(   r)   r      r   z_ix_constraint_sig.column_namesTuple[Optional[str], ...]c                 C  r   )Nc                 S  s   g | ]}t |d dqS )rH   N)getattrr   r(   r(   r)   r      s    z<_ix_constraint_sig.column_names_optional.<locals>.<listcomp>)r   rE   expressionsr&   r(   r(   r)   column_names_optional   s   z(_ix_constraint_sig.column_names_optionalc                 C  s   dS )NTr(   r&   r(   r(   r)   rk      s   z_ix_constraint_sig.is_namedc                 C  ro   rO   )r   r   r&   r(   r(   r)   rm      rq   z_ix_constraint_sig.unnamedNrx   )rW   r"   rI   r   rE   r   r!   rN   ry   r   )r!   r   )r>   r?   r@   rJ   rA   rC   rP   rY   r]   r   rz   r   r   r   rk   rm   r(   r(   r(   r)   r      s"   
 

	


r   c                   @  s6   e Zd ZdZedddZdddZejdd Z	dS )_fk_constraint_sigTr!   rN   c                 C  r|   )Nforeign_key_constraintr~   r0   r(   r(   r)   rP      r   z_fk_constraint_sig._registerrW   r"   rI   r   rE   r   c                 C  s   || _ || _|| _t|j| _t|\
| _| _| _	| _
| _| _}}}}| j| jt| j	| j
| jt| jf|rD| dkr@d n| nd |rS| dkrOd n| nd |r^| dkr^dn|rbdndf | _d S )Nz	no actiondeferredinitially_deferrable
deferrableznot deferrable)rM   rI   rE   r   r   rH   _fk_specsource_schemasource_tablesource_columnstarget_schematarget_tabletarget_columnsr   lowerrG   )r'   rW   rI   rE   onupdateondeleter   	initiallyr(   r(   r)   rY      sH   


z_fk_constraint_sig.__init__c                 C  s$   | j | jt| j| j| jt| jfS rO   )r   r   r   r   r   r   r   r&   r(   r(   r)   rn   4  s   z%_fk_constraint_sig.unnamed_no_optionsNrx   )rW   r"   rI   r   rE   r   r!   rN   )
r>   r?   r@   rK   rC   rP   rY   r   rz   rn   r(   r(   r(   r)   r      s    
4r   rc   r!   TypeGuard[_ix_constraint_sig]c                 C  rl   rO   )rJ   rc   r(   r(   r)   r   @     r   TypeGuard[_uq_constraint_sig]c                 C  rl   rO   )rL   r   r(   r(   r)   r   D  r   r   TypeGuard[_fk_constraint_sig]c                 C  rl   rO   )rK   r   r(   r(   r)   	is_fk_sigH  r   r   N)rc   rD   r!   r   )rc   rD   r!   r   )rc   rD   r!   r   )*
__future__r   typingr   r   r   r   r   r   r	   r
   r   r   r   r   sqlalchemy.sql.schemar   r   r   r   typing_extensionsr    r   r   r   alembic.autogenerate.apir   alembic.ddl.implr   CompareConstraintTyper   r   rA   r   rD   r{   r   r   r   r   r   r(   r(   r(   r)   <module>   sF   %R&3
G
