Ë
    ¹ûàg�  ã                   ó”   — 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)ÚCURSORÚGET_ITERATOR_CHUNK_SIZEÚ
NO_RESULTS)Ú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        «      }|r|5  |j
                  cd d d «       S y# 1 sw Y   yxY w)Nr   )Ú	alias_mapÚwhereÚget_compilerÚexecute_sqlr   Úrowcount)ÚselfÚtabler   ÚusingÚcursors        ú]/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/django/db/models/sql/subqueries.pyÚdo_queryzDeleteQuery.do_query   sa   € Ø §¡°Ñ!6Ð7ˆŒØˆŒ
Ø×"Ñ" 5Ó)×5Ñ5´fÓ=ˆÙØñ 'Ø—‘÷'ñ 'à÷'àús   ÁAÁA&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ð	ð Ðó    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 ©N)ÚsuperÚ__init__Ú_setup_query)r   ÚargsÚkwargsÚ	__class__s      €r   r5   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   r6   zUpdateQuery._setup_query9   s   € ð
 ˆŒØˆÔØ!ˆÕr)   c                 ób   •— t         ‰| �  «       }| j                  j                  «       |_        |S r3   )r4   Úcloner=   Úcopy)r   Úobjr9   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$   r;   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                 ó  — g }|j                  «       D ]Û  \  }}| j                  «       j                  |«      }|j                  xr |j                    xs |j                   }|j
                  j                  j                  }|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.
        zMCannot update model field %r (only non-relations and foreign keys permitted).)Úitemsr   Ú	get_fieldÚauto_createdÚconcreteÚmodelÚ_metaÚconcrete_modelÚis_relationÚmany_to_manyr   Úadd_related_updateÚappendÚadd_update_fields)r   r;   Ú
values_seqÚnameÚvalr&   ÚdirectrK   s           r   rD   zUpdateQuery.add_update_valuesP   sø   € ð ˆ
ØŸ™›ò 	3‰IˆD�#Ø—M‘M“O×-Ñ-¨dÓ3ˆEà×'Ñ'Ò>°·±Ð,>Ð?ÒUÀuÇ~Á~ÐCUð ð —K‘K×%Ñ%×4Ñ4ˆEÙ˜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ÚhasattrrX   r;   rQ   )r   rS   r&   rK   rU   s        r   rR   zUpdateQuery.add_update_fieldsh   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   rK   r&   Úvalues       r   rP   zUpdateQuery.add_related_updatew   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.
        rC   )r=   rG   r	   r;   r<   r!   rQ   )r   ÚresultrK   r;   Ú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.   r5   r6   r?   rE   rD   rR   rP   rc   Ú__classcell__©r9   s   @r   r	   r	   0   s4   ø„ Ùà"€Hôò"ôò
=ò2ò0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 r3   )r4   r5   ÚfieldsÚobjsrh   ri   rj   )r   rh   ri   rj   r7   r8   r9   s         €r   r5   zInsertQuery.__init__”   sG   ø€ ô 	‰Ñ˜$Ð) &Ò)ØˆŒØˆŒ	Ø&ˆÔØ*Ò0¨bˆÔØ*Ò0¨bˆÕr)   c                 ó.   — || _         || _        || _        y r3   )rl   rm   Úraw)r   rl   rm   ro   s       r   Úinsert_valueszInsertQuery.insert_valuesž   s   € ØˆŒØˆŒ	Øˆ�r)   )F)r*   r+   r,   r.   r5   rp   rd   re   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 r3   )Úinner_queryr4   r5   )r   rK   rt   r9   s      €r   r5   zAggregateQuery.__init__¬   s   ø€ Ø&ˆÔÜ‰Ñ˜Õr)   )r*   r+   r,   r-   r.   r5   rd   re   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>ry      sQ   ðñõ .ß VÑ VÝ ,â
I€ô!�%ô !ôH^�%ô ^ôB�%ô ô&
 �Uõ 
 r)   