
    g3                         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   )
ForeignKey)Integer)select)String)testingc                   Z   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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/AdoubleTech/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   r4   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 )Nr.   r/   T)	recursivec1r"   )r0   r#   r<   r    r=   r=   )r)   r   r
   r1   r2   r   r3   r4   alias	union_allr   r   r(   order_bydescr   r5   )r6   r+   r   r4   	cte_aliasst1r7   s          r    test_select_recursive_round_tripz(CTETest.test_select_recursive_round_tripG   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 )Nr.   r/   r!   ))r   r"   r   )r   r#   r   )r$   r%   r   )r)   r   r   r
   r1   r2   r   r3   r4   r(   r*   from_selectr   r@   r   r5   r6   r+   r   r   r4   s        r   "test_insert_from_select_round_tripz*CTETest.test_insert_from_select_round_tripa   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!   r.   r/   r&   )r   )r   r    N)r   r"   r&   )r   r#   r&   )r$   r%   r&   r&   r'   r   )r)   r   r   r(   r*   rF   r
   r1   r2   r   r3   r4   updatevaluesr   r@   r   r5   rG   s        r   test_update_from_round_tripz#CTETest.test_update_from_round_tripv   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!   r.   r/   rJ   rK   )r)   r   r   r(   r*   rF   r
   r1   r2   r   r3   r4   deleter   r@   r   r5   rG   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 rP   )r)   r   r   r(   r*   rF   r
   r1   r2   r   r3   r4   rQ   r   scalar_subqueryr   r@   r5   rG   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   N)__name__
__module____qualname____backend____requires__run_insertsrun_deletesclassmethodr   r,   r8   rD   rH   r   requiresctes_with_update_deleteupdate_fromrN   delete_fromrR   rU    r   r   r   r      s    KLKK
 
" 

 

*
4
* --!!
 " .
B --!!
 " .
6 --
 .
r   r   N) r   
assertionsr   schemar   r   r   r	   r
   r   r   
TablesTestr   rb   r   r   <module>rg      s6            
h!! 
r   