§
    Ÿj  ã                   ó®   — 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dS )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dS )r   zA DELETE SQL query.ÚSQLDeleteCompilerc                 ó’   — || j         |         i| _         || _        |                      |¦  «                             t          ¦  «        S ©N)Ú	alias_mapÚwhereÚget_compilerÚexecute_sqlr   )ÚselfÚtabler   Úusings       úl/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/django/db/models/sql/subqueries.pyÚdo_queryzDeleteQuery.do_query   s>   € Ø ¤°Ô!6Ð7ˆŒØˆŒ
Ø× Ò  Ñ'Ô'×3Ò3µIÑ>Ô>Ð>ó    c                 óz  — d}|                       ¦   «         j        }t          dt          |¦  «        t          ¦  «        D ]{}|                      ¦   «          |                      |j        › d�|||t          z   …         ¦  «         ||                      |                       ¦   «         j	        | j
        |¬¦  «        z  }Œ||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ÔEð 	ð 	ˆFØ×ÒÑÔÐØ�OŠOØ”=Ð&Ð&Ð&Ø˜ Õ*AÑ!AÐAÔBñô ð ð ˜4Ÿ=š=Ø—’‘”Ô(¨$¬*¸Eð )ñ ô ñ ˆKˆ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                 ób   •—  t          ¦   «         j        |i |¤Ž |                      ¦   «          d S r   )ÚsuperÚ__init__Ú_setup_query)r   ÚargsÚkwargsÚ	__class__s      €r   r3   zUpdateQuery.__init__5   s7   ø€ Ø�‰ŒÔ˜$Ð) &Ð)Ð)Ð)Ø×ÒÑÔÐÐÐr   c                 ó0   — g | _         d| _        i | _        dS )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                 ó„   •— t          ¦   «                              ¦   «         }| j                             ¦   «         |_        |S r   )r2   Úcloner;   Úcopy)r   Úobjr7   s     €r   r=   zUpdateQuery.cloneB   s0   ø€ Ý‰gŒg�mŠm‰oŒoˆØ"Ô2×7Ò7Ñ9Ô9ˆÔØˆ
r   c                 óJ  — |                       |¦  «         t          dt          |¦  «        t          ¦  «        D ]i}|                      ¦   «          |                      d|||t          z   …         ¦  «         |                      |¦  «                             t          ¦  «         Œjd S )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   s¦   € Ø×Ò˜vÑ&Ô&Ð&Ý˜A�s 7™|œ|Õ-DÑEÔEð 	=ð 	=ˆFØ×ÒÑÔÐØ�OŠOØ˜' &¨6Õ4KÑ+KÐ"KÔLñô ð ð ×Ò˜eÑ$Ô$×0Ò0µÑ<Ô<Ð<Ð<ð	=ð 	=r   c                 ó*  — g }|                      ¦   «         D ]è\  }}|                      ¦   «                              |¦  «        }|j        o|j          p|j         }|j        j        j        }|j        dk    r|j        j	        rt          d¦  «        ‚|r|j        r|j        rt          d|z  ¦  «        ‚||                      ¦   «         j        ur|                      |||¦  «         ŒÐ|                     |||f¦  «         Œé|                      |¦  «        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ð 	3‰IˆD�#Ø—M’M‘O”O×-Ò-¨dÑ3Ô3ˆEàÔ'Ð>°´Ð,>Ð?ÐUÀuÄ~ÐCUð ð ”KÔ%Ô4ˆEØŒz˜TÒ!Ð! e¤kÔ&AÐ!Ý ØPñô ð ð ð ˜eÔ/ð °EÔ4Fð Ý ð/Ø16ñ7ñô ð ð ˜DŸMšM™OœOÔ:Ð:Ð:Ø×'Ò'¨¨u°cÑ:Ô:Ð:ØØ×Ò˜u e¨SÐ1Ñ2Ô2Ð2Ð2Ø×%Ò% jÑ1Ô1Ð1r   c                 ó²   — |D ]S\  }}}|j         rŒt          |d¦  «        r|                     | dd¬¦  «        }| j                             |||f¦  «         ŒTdS )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ð 	4ÑˆE�5˜#àŒð ØÝ�sÐ0Ñ1Ô1ð Uà×,Ò,¨T¸uÈtÐ,ÑTÔT�ØŒK×Ò  u¨cÐ2Ñ3Ô3Ð3Ð3ð	4ð 	4r   c                 óh   — | j                              |g ¦  «                             |d|f¦  «         dS )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{   s8   € ð 	Ô×'Ò'¨¨rÑ2Ô2×9Ò9¸5À$ÈÐ:NÑOÔOÐOÐOÐOr   c                 ó   — | j         sg S g }| j                              ¦   «         D ]X\  }}t          |¦  «        }||_        | j        �!|                     d| j        |         ¦  «         |                     |¦  «         ŒY|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.
        NrA   )r;   rE   r	   r9   r:   r!   rQ   )r   ÚresultrI   r9   Úquerys        r   Úget_related_updateszUpdateQuery.get_related_updatesƒ   s�   € ð Ô#ð 	ØˆIØˆØ!Ô1×7Ò7Ñ9Ô9ð 	!ð 	!‰MˆE�6Ý Ñ&Ô&ˆEØ!ˆEŒLØÔÐ+Ø× Ò  ¨4Ô+;¸EÔ+BÑCÔCÐCØ�MŠM˜%Ñ Ô Ð Ð Øˆr   )r)   r*   r+   r,   r-   r3   r4   r=   rC   rB   rR   rP   rb   Ú__classcell__©r7   s   @r   r	   r	   0   s¹   ø€ € € € € ØÐà"€Hðð ð ð ð ð"ð "ð "ðð ð ð ð ð
=ð =ð =ð2ð 2ð 2ð84ð 4ð 4ðPð Pð 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                óˆ   •—  t          ¦   «         j        |i |¤Ž g | _        g | _        || _        |pg | _        |pg | _        d S r   )r2   r3   ÚfieldsÚobjsrg   rh   ri   )r   rg   rh   ri   r5   r6   r7   s         €r   r3   zInsertQuery.__init__˜   sW   ø€ ð 	�‰ŒÔ˜$Ð) &Ð)Ð)Ð)ØˆŒØˆŒ	Ø&ˆÔØ*Ð0¨bˆÔØ*Ð0¨bˆÔÐÐr   Fc                 ó0   — || _         || _        || _        d S 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
   •   sd   ø€ € € € € Ø"€Hð "&°TÈð1ð 1ð 1ð 1ð 1ð 1ð 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                 óX   •— || _         t          ¦   «                              |¦  «         d S 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   ¨   sI   ø€ € € € € ðð ð
 &€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      s0  ððð ð .Ð -Ð -Ð -Ð -Ð -ðð ð ð ð ð ð ð ð ð ð
 -Ð ,Ð ,Ð ,Ð ,Ð ,à
IÐ
IÐ
I€ðð ð ð ð �%ñ ô ð ð@bð bð bð bð b�%ñ bô bð bðJð ð ð ð �%ñ ô ð ð&
 ð 
 ð 
 ð 
 ð 
 �Uñ 
 ô 
 ð 
 ð 
 ð 
 r   