
    hh                         S r SSKJr  SSKJrJrJr  SSKJr  / SQr	 " S S\5      r
 " S S	\5      r " S
 S\5      r " S S\5      rg)zR
Query subclasses which provide extra functionality beyond simple data retrieval.
    )
FieldError)GET_ITERATOR_CHUNK_SIZE
NO_RESULTS	ROW_COUNT)Query)DeleteQueryUpdateQueryInsertQueryAggregateQueryc                   (    \ rS rSrSrSrS rS rSrg)r      zA DELETE SQL query.SQLDeleteCompilerc                     XR                   U   0U l         X l        U R                  U5      R                  [        5      $ N)	alias_mapwhereget_compilerexecute_sqlr   )selftabler   usings       ZD:\Anime\Ugyen\janka_web_project\venv\Lib\site-packages\django/db/models/sql/subqueries.pydo_queryDeleteQuery.do_query   s6    !67
  '33I>>    c                 Z   SnU R                  5       R                  n[        S[        U5      [        5       Hp  nU R                  5         U R                  UR                   S3XU[        -    5        X0R                  U R                  5       R                  U R                  US9-  nMr     U$ )z
Set up and execute delete queries for all the objects in pk_list.

More than one physical query may be executed if there are a
lot of values in pk_list.
r   __in)r   )get_metapkrangelenr   clear_where
add_filterattnamer   db_tabler   )r   pk_listr   num_deletedfieldoffsets         r   delete_batchDeleteQuery.delete_batch   s     ""As7|-DEFOO==/&*A!AB ==(($**E )  K F r   )r   r   N)	__name__
__module____qualname____firstlineno____doc__compilerr   r*   __static_attributes__ r   r   r   r      s    "H?
r   r   c                   `   ^  \ rS rSrSrSrU 4S jrS rU 4S jrS r	S r
S	 rS
 rS rSrU =r$ )r	   0   zAn UPDATE SQL query.SQLUpdateCompilerc                 F   > [         TU ]  " U0 UD6  U R                  5         g r   )super__init___setup_query)r   argskwargs	__class__s      r   r9   UpdateQuery.__init__5   s!    $)&)r   c                 .    / U l         SU l        0 U l        g)z
Run on initialization and at the end of chaining. Any attributes that
would normally be set in __init__() should go here instead.
N)valuesrelated_idsrelated_updates)r   s    r   r:   UpdateQuery._setup_query9   s    
 !r   c                 b   > [         TU ]  5       nU R                  R                  5       Ul        U$ r   )r8   clonerB   copy)r   objr=   s     r   rE   UpdateQuery.cloneB   s*    gmo"22779
r   c                    U R                  U5        [        S[        U5      [        5       HR  nU R	                  5         U R                  SXU[        -    5        U R                  U5      R                  [        5        MT     g )Nr   pk__in)	add_update_valuesr    r!   r   r"   r#   r   r   r   )r   r&   r@   r   r)   s        r   update_batchUpdateQuery.update_batchG   sl    v&As7|-DEFOO'64K+KL e$00< Fr   c                    / nUR                  5        GH7  u  p4U R                  5       R                  U5      nUR                  =(       a    UR                  (       + (       + =(       d    UR                  (       + nUR
                  R                  R                  nUR                  S:X  a&  UR                  R                  (       a  [        S5      eU(       a"  UR                  (       a  UR                  (       a  [        SU-  5      eXpR                  5       R                  La  U R                  XuU5        GM$  UR                  XWU45        GM:     U R                  U5      $ )z
Convert a dictionary of field name to value mappings into an update
query. This is the entry point for the public update() method on
querysets.
r   z:Composite primary key fields must be updated individually.zMCannot update model field %r (only non-relations and foreign keys permitted).)itemsr   	get_fieldauto_createdconcretemodel_metaconcrete_modelnameis_composite_pkr   is_relationmany_to_manyadd_related_updateappendadd_update_fields)r   r@   
values_seqrV   valr(   directrS   s           r   rK   UpdateQuery.add_update_valuesP   s    
IDMMO--d3E''>,>?Uu~~CU  KK%%44EzzT!ekk&A&A P  e//E4F4F /167  MMO:::''c:uS12% (& %%j11r   c                     U HX  u  p#nUR                   (       a  M  [        US5      (       a  UR                  U SSS9nU R                  R	                  X#U45        MZ     g)z
Append a sequence of (field, model, value) triples to the internal list
that will be used to generate the UPDATE query. Might be more usefully
called add_update_targets() to hint at the extra information here.
resolve_expressionFT)allow_joinsfor_saveN)	generatedhasattrrb   r@   r[   )r   r]   r(   rS   r^   s        r   r\   UpdateQuery.add_update_fieldsl   sY     ",E#s011,,Tut,TKKc23 ",r   c                 `    U R                   R                  U/ 5      R                  USU45        g)z
Add (name, value) to an update query for an ancestor model.

Update are coalesced so that only one update query per ancestor is run.
N)rB   
setdefaultr[   )r   rS   r(   values       r   rZ   UpdateQuery.add_related_update{   s,     	''r2995$:NOr   c                    U R                   (       d  / $ / nU R                   R                  5        HS  u  p#[        U5      nX4l        U R                  b  UR                  SU R                  U   5        UR                  U5        MU     U$ )z
Return a list of query objects: one for each update required to an
ancestor model. Each query will have the same filtering conditions as
the current query but will only update a single table.
rJ   )rB   rO   r	   r@   rA   r#   r[   )r   resultrS   r@   querys        r   get_related_updatesUpdateQuery.get_related_updates   s{     ##I!11779ME&E!L+  4+;+;E+BCMM%  : r   )rA   rB   r@   )r,   r-   r.   r/   r0   r1   r9   r:   rE   rL   rK   r\   rZ   ro   r2   __classcell__r=   s   @r   r	   r	   0   s9    "H"
=284P r   r	   c                   B   ^  \ rS rSrSrSSSS.U 4S jjrSS jrSrU =r$ )	r
      SQLInsertCompilerN)on_conflictupdate_fieldsunique_fieldsc                   > [         TU ]  " U0 UD6  / U l        / U l        Xl        U=(       d    / U l        U=(       d    / U l        g r   )r8   r9   fieldsobjsrv   rw   rx   )r   rv   rw   rx   r;   r<   r=   s         r   r9   InsertQuery.__init__   sE     	$)&)	&*0b*0br   c                 (    Xl         X l        X0l        g r   )rz   r{   raw)r   rz   r{   r~   s       r   insert_valuesInsertQuery.insert_values   s    	r   )rz   r{   rv   r~   rx   rw   )F)	r,   r-   r.   r/   r1   r9   r   r2   rq   rr   s   @r   r
   r
      s%    "H "&T1 1 r   r
   c                   0   ^  \ rS rSrSrSrU 4S jrSrU =r$ )r      zi
Take another query as a parameter to the FROM clause and only select the
elements in the provided list.
SQLAggregateCompilerc                 0   > X l         [        TU ]	  U5        g r   )inner_queryr8   r9   )r   rS   r   r=   s      r   r9   AggregateQuery.__init__   s    &r   )r   )	r,   r-   r.   r/   r0   r1   r9   r2   rq   rr   s   @r   r   r      s    
 &H   r   r   N)r0   django.core.exceptionsr   django.db.models.sql.constantsr   r   r   django.db.models.sql.queryr   __all__r   r	   r
   r   r3   r   r   <module>r      sW    . 
 -
I% @b% bJ% &
 U 
 r   