
    h^                         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  G d dej                        Zy)   )fixtures)eq_)Column)Table   )column)
ForeignKey)Integer)select)String)testing)valuesc                   "   e Zd ZdZdZdZdZed        Zed        Z	d Z
d Zd Zej                  j                  ej                  j                   d	               Zej                  j                  ej                  j$                  d
               Zej                  j                  d        Z ej*                  dddg       ej*                  dddg       ej*                  dddg      ej                  j,                  d                             Zy)CTETestT)cteseachc                    t        d|t        dt        d      t        dt        d            t        dt	        d                   t        d	|t        dt        d      t        dt        d            t        dt                     y )
N
some_tableidT)primary_keydata2   	parent_idzsome_table.idsome_other_table)r   r   r
   r   r	   )clsmetadatas     _/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/sqlalchemy/testing/suite/test_cte.pydefine_tableszCTETest.define_tables   sm    4d366":&;
? ;<	
 	4d366":&;(	
    c                     |j                  | j                  j                  j                         ddd ddddddddddd	ddd
dddg       y )N   d1r   r   r   r   d2r   d3   d4   d5)executetablesr   insert)r   
connections     r   insert_datazCTETest.insert_data/   s]    JJ!!((*$T:$Q7$Q7$Q7$Q7		
r   c                    | j                   j                  }t        |      j                  |j                  j
                  j                  g d            j                  d      }|j                  t        |j                  j
                        j                  |j                  j
                  j                  ddg                  }t        |j                         dg       y )Nr$   r%   r'   some_cter'   r)   r'   )r+   r   r   wherecr   in_cter*   r   fetchall)selfr-   r   r6   results        r   #test_select_nonrecursive_round_tripz+CTETest.test_select_nonrecursive_round_trip<   s    [[++
 :U:<<$$(();<=S_ 	
 ##355::$$SUUZZ^^T4L%AB
 	FOOy)r   c                    | j                   j                  }t        |      j                  |j                  j
                  j                  g d            j                  dd      }|j                  d      }|j                         }|j                  t        |      j                  |j                  j                  |j                  j                  k(              }|j                  t        |j                  j
                        j                  |j                  j
                  dk7        j                  |j                  j
                  j                                     }t        |j!                         g d       y )Nr0   r1   T)	recursivec1r$   )r2   r%   r>   r"   r?   r?   )r+   r   r   r3   r4   r   r5   r6   alias	union_allr   r   r*   order_bydescr   r7   )r8   r-   r   r6   	cte_aliasst1r9   s          r    test_select_recursive_round_tripz(CTETest.test_select_recursive_round_tripI   s   [[++
 :U:<<$$(();<=StS, 	 IIdO	  mm3Kceehh)++*?*??@
 ##355::U355::%&Xceejjoo'(

 	OOB	
r   c                    | j                   j                  }| j                   j                  }t        |      j	                  |j
                  j                  j                  g d            j                  d      }|j                  |j                         j                  g dt        |                   t        |j                  t        |      j                  |j
                  j                              j                         g d       y )Nr0   r1   r#   ))r   r$   r!   )r   r%   r!   )r&   r'   r   )r+   r   r   r   r3   r4   r   r5   r6   r*   r,   from_selectr   rB   r   r7   r8   r-   r   r   r6   s        r   "test_insert_from_select_round_tripz*CTETest.test_insert_from_select_round_tripc   s    [[++
;;77 :U:<<$$(();<=S_ 	
 	##%11+VC[	

 	'(112B2D2D2G2GHhj6		
r   c                    | j                   j                  }| j                   j                  }|j                  |j	                         j                  g dt        |                   t        |      j                  |j                  j                  j                  g d            j                  d      }|j                  |j                         j                  d      j                  |j                  j                  |j                  j                  k(               t        |j                  t        |      j                  |j                  j                               j#                         g d       y )Nr#   r0   r1   r(   )r   )r!   r"   N)r   r$   r(   )r   r%   r(   )r&   r'   r(   r(   r)   r   )r+   r   r   r*   r,   rH   r   r3   r4   r   r5   r6   updater   r   rB   r   r7   rI   s        r   test_update_from_round_tripz#CTETest.test_update_from_round_tripx   s    [[++
;;77##%11+VJ-?	
 :U:<<$$(();<=S_ 	
 	##%VaV U#%%**ceejj89	

 	'(112B2D2D2G2GHhj		
r   c                    | j                   j                  }| j                   j                  }|j                  |j	                         j                  g dt        |                   t        |      j                  |j                  j                  j                  g d            j                  d      }|j                  |j                         j                  |j                  j                  |j                  j                  k(               t        |j                  t        |      j                  |j                  j                              j!                         ddg       y Nr#   r0   r1   rL   rM   )r+   r   r   r*   r,   rH   r   r3   r4   r   r5   r6   deleter   rB   r   r7   rI   s        r   test_delete_from_round_tripz#CTETest.test_delete_from_round_trip   s    [[++
;;77##%11+VJ-?	
 :U:<<$$(();<=S_ 	
 	##%++ ""''355::5	

 	'(112B2D2D2G2GHhjl+		
r   c           	      n   | j                   j                  }| j                   j                  }|j                  |j	                         j                  g dt        |                   t        |      j                  |j                  j                  j                  g d            j                  d      }|j                  |j                         j                  |j                  j                  t        |j                  j                        j                  |j                  j                  |j                  j                  k(        j                         k(               t        |j                  t        |      j!                  |j                  j                              j#                         ddg       y rQ   )r+   r   r   r*   r,   rH   r   r3   r4   r   r5   r6   rR   r   scalar_subqueryr   rB   r7   rI   s        r   "test_delete_scalar_subq_round_tripz*CTETest.test_delete_scalar_subq_round_trip   sG   [[++
;;77##%11+VJ-?	
 :U:<<$$(();<=S_ 	
 	##%++ ""''#%%**%suuxx#3#5#5#8#889 "#	
 	'(112B2D2D2G2GHhjl+		
r   values_namedF	cte_namedliteral_bindsc                 ,   t        t        dt              t        dt              t	        |      |rdnd       j                  ddg      j                  |rdnd       }t        |      }|j                  |      j                         }t        |ddg       y )Ncol1col2z	some name)rY   name)ar   )br   cte1)r   r   r   r
   boolr   r6   r   r*   allr   )r8   r-   rW   rX   rY   r`   stmtrowss           r   test_values_named_via_ctez!CTETest.test_values_named_via_cte   s     vv&vw'"=1$0[d	 T8X&'S9$/ 	 d|!!$'++-D8X&'r   N)__name__
__module____qualname____backend____requires__run_insertsrun_deletesclassmethodr   r.   r:   rF   rJ   r   requiresctes_with_update_deleteupdate_fromrO   delete_fromrS   rV   	variationctes_with_valuesre    r   r   r   r      sE   KLKK
 
" 

 

*
4
* --!!
 " .
B --!!
 " .
6 --
 .
< W~e}5W{T5M2Wu6&&( ' 7 3 6(r   r   N) r   
assertionsr   schemar   r   r   r	   r
   r   r   r   r   
TablesTestr   rt   r   r   <module>ry      s<              W(h!! W(r   