Ë
    ò%9j  ã                   ó”   — d Z ddlmZ ddlmZmZmZ ddlmZ g d¢Z	 G d„ de«      Z
 G d„ d	e«      Z G d
„ de«      Z G d„ de«      Zy)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                   ó    — e Zd ZdZdZd„ Zd„ Zy)r   zA DELETE SQL query.ÚSQLDeleteCompilerc                 ó„   — || j                   |   i| _         || _        | j                  |«      j                  t        «      S ©N)Ú	alias_mapÚwhereÚget_compilerÚexecute_sqlr   )ÚselfÚtabler   Úusings       ú[/var/www/html/truck-me/venv/lib/python3.12/site-packages/django/db/models/sql/subqueries.pyÚdo_queryzDeleteQuery.do_query   s:   € Ø §¡°Ñ!6Ð7ˆŒØˆŒ
Ø× Ñ  Ó'×3Ñ3´IÓ>Ð>ó    c                 ó`  — d}| j                  «       j                  }t        dt        |«      t        «      D ]t  }| j                  «        | j                  |j                  › d�|||t        z    «       || j                  | j                  «       j                  | j                  |¬«      z  }Œv |S )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_batchzDeleteQuery.delete_batch   s¨   € ð ˆØ—‘“×"Ñ"ˆÜ˜Aœs 7›|Ô-DÓEò 	ˆFØ×ÑÔØ�O‰OØ—=‘=�/ Ð&Ø˜ Ô*AÑ!AÐBôð ˜4Ÿ=™=Ø—‘“×(Ñ(¨$¯*©*¸Eð )ó ñ ‰Kð	ð Ðr   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úcompilerr   r(   © r   r   r   r      s   „ Ùà"€Hò?ó
r   r   c                   óT   ‡ — e Zd ZdZdZˆ fd„Zd„ Zˆ fd„Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zˆ xZS )r	   zAn UPDATE SQL query.ÚSQLUpdateCompilerc                 óD   •— t        ‰| �  |i |¤Ž | j                  «        y r   )ÚsuperÚ__init__Ú_setup_query)r   ÚargsÚkwargsÚ	__class__s      €r   r3   zUpdateQuery.__init__5   s!   ø€ Ü‰Ñ˜$Ð) &Ò)Ø×ÑÕr   c                 ó.   — g | _         d| _        i | _        y)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   r4   zUpdateQuery._setup_query9   s   € ð
 ˆŒØˆÔØ!ˆÕr   c                 ób   •— t         ‰| �  «       }| j                  j                  «       |_        |S r   )r2   Úcloner;   Úcopy)r   Úobjr7   s     €r   r=   zUpdateQuery.cloneB   s*   ø€ Ü‰g‰m‹oˆØ"×2Ñ2×7Ñ7Ó9ˆÔØˆ
r   c                 ó  — | j                  |«       t        dt        |«      t        «      D ]R  }| j	                  «        | j                  d|||t        z    «       | j                  |«      j                  t        «       ŒT y )Nr   Úpk__in)	Úadd_update_valuesr   r   r   r    r!   r   r   r   )r   r$   r9   r   r'   s        r   Úupdate_batchzUpdateQuery.update_batchG   sr   € Ø×Ñ˜vÔ&Ü˜Aœs 7›|Ô-DÓEò 	=ˆFØ×ÑÔØ�O‰OØ˜' &¨6Ô4KÑ+KÐLôð ×Ñ˜eÓ$×0Ñ0´Õ<ñ	=r   c                 óh  — g }|j                  «       D �]  \  }}| j                  «       j                  |«      }|j                  xr |j                    xs |j                   }|j
                  j                  j                  }|j                  dk(  r!|j                  j                  rt        d«      ‚|r|j                  r|j                  rt        d|z  «      ‚|| j                  «       j                  ur| j                  |||«       Œù|j                  |||f«       �Œ | j                  |«      S )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   r9   Ú
values_seqrL   Úvalr&   ÚdirectrI   s           r   rB   zUpdateQuery.add_update_valuesP   s"  € ð ˆ
ØŸ™›ó 	3‰IˆD�#Ø—M‘M“O×-Ñ-¨dÓ3ˆEà×'Ñ'Ò>°·±Ð,>Ð?ÒUÀuÇ~Á~ÐCUð ð —K‘K×%Ñ%×4Ñ4ˆEØ�z‰z˜TÒ! e§k¡k×&AÒ&AÜ ØPóð ñ ˜e×/Ò/°E×4FÒ4FÜ ð/Ø16ñ7óð ð ˜DŸM™M›O×:Ñ:Ñ:Ø×'Ñ'¨¨u°cÔ:ØØ×Ñ˜u e¨SÐ1Ö2ð%	3ð& ×%Ñ% jÓ1Ð1r   c                 ó°   — |D ]Q  \  }}}|j                   rŒt        |d«      r|j                  | dd¬«      }| j                  j	                  |||f«       ŒS y)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ÚhasattrrW   r9   rQ   )r   rS   r&   rI   rT   s        r   rR   zUpdateQuery.add_update_fieldsl   s_   € ð ",ò 	4ÑˆE�5˜#à�ŠØÜ�sÐ0Ô1à×,Ñ,¨T¸uÈtÐ,ÓT�Ø�K‰K×Ñ  u¨cÐ2Õ3ñ	4r   c                 ó`   — | j                   j                  |g «      j                  |d|f«       y)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)r;   Ú
setdefaultrQ   )r   rI   r&   Úvalues       r   rP   zUpdateQuery.add_related_update{   s,   € ð 	×Ñ×'Ñ'¨¨rÓ2×9Ñ9¸5À$ÈÐ:NÕOr   c                 ó  — | j                   sg S g }| j                   j                  «       D ]S  \  }}t        |«      }||_        | j                  �|j                  d| j                  |   «       |j                  |«       ŒU |S )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.
        rA   )r;   rE   r	   r9   r:   r!   rQ   )r   ÚresultrI   r9   Úquerys        r   Úget_related_updateszUpdateQuery.get_related_updatesƒ   s„   € ð ×#Ò#ØˆIØˆØ!×1Ñ1×7Ñ7Ó9ò 	!‰MˆE�6Ü Ó&ˆEØ!ˆEŒLØ×ÑÐ+Ø× Ñ  ¨4×+;Ñ+;¸EÑ+BÔCØ�M‰M˜%Õ ð	!ð ˆr   )r)   r*   r+   r,   r-   r3   r4   r=   rC   rB   rR   rP   rb   Ú__classcell__©r7   s   @r   r	   r	   0   s4   ø„ Ùà"€Hôò"ôò
=ò2ò84òPör   r	   c                   ó4   ‡ — e Zd ZdZddddœˆ fd„
Zdd„Zˆ xZS )r
   ÚSQLInsertCompilerN)Úon_conflictÚupdate_fieldsÚunique_fieldsc                óz   •— t        ‰| �  |i |¤Ž g | _        g | _        || _        |xs g | _        |xs g | _        y r   )r2   r3   ÚfieldsÚobjsrg   rh   ri   )r   rg   rh   ri   r5   r6   r7   s         €r   r3   zInsertQuery.__init__˜   sG   ø€ ô 	‰Ñ˜$Ð) &Ò)ØˆŒØˆŒ	Ø&ˆÔØ*Ò0¨bˆÔØ*Ò0¨bˆÕr   c                 ó.   — || _         || _        || _        y r   )rk   rl   Úraw)r   rk   rl   rn   s       r   Úinsert_valueszInsertQuery.insert_values¢   s   € ØˆŒØˆŒ	Øˆ�r   )F)r)   r*   r+   r-   r3   ro   rc   rd   s   @r   r
   r
   •   s   ø„ Ø"€Hð "&°TÈö1÷r   r
   c                   ó&   ‡ — e Zd ZdZdZˆ fd„Zˆ xZS )r   zu
    Take another query as a parameter to the FROM clause and only select the
    elements in the provided list.
    ÚSQLAggregateCompilerc                 ó2   •— || _         t        ‰| �	  |«       y r   )Úinner_queryr2   r3   )r   rI   rs   r7   s      €r   r3   zAggregateQuery.__init__°   s   ø€ Ø&ˆÔÜ‰Ñ˜Õr   )r)   r*   r+   r,   r-   r3   rc   rd   s   @r   r   r   ¨   s   ø„ ñð
 &€H÷ ð  r   r   N)r,   Údjango.core.exceptionsr   Údjango.db.models.sql.constantsr   r   r   Údjango.db.models.sql.queryr   Ú__all__r   r	   r
   r   r.   r   r   ú<module>rx      sW   ðñõ .÷ñ õ
 -â
I€ô�%ô ô@b�%ô bôJ�%ô ô&
 �Uõ 
 r   