Ë
    ¹ûàgQÇ ã                   ó$  — d Z ddlZddlZddlZddlZddlmZmZ ddlm	Z	m
Z
 ddlmZmZmZ ddlmZ ddlmZmZ ddlmZmZmZ dd	lmZ dd
lmZ ddlmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ ddl%m&Z& ddl'm(Z( ddl)m*Z* ddl+m,Z,m-Z-m.Z. ddl/m0Z0m1Z1m2Z2m3Z3 ddl4m5Z5m6Z6m7Z7m8Z8 ddl9m:Z:m;Z;m<Z<m=Z=m>Z> ddl?m@Z@ ddlAmBZB ddlCmDZD ddgZE eBd«      ZF eBd«      ZGd„ ZHd„ ZId„ ZJd„ ZKd„ ZL edd «      ZM G d!„ d«      ZN ed"d#«      ZO G d$„ de«      ZPd(d%„ZQ G d&„ d'«      ZRy))aW  
Create SQL statements for QuerySets.

The code in here encapsulates all of the SQL construction so that QuerySets
themselves do not have to (and could be backed by things other than SQL
databases). The abstraction barrier only works one way: this module has to know
all about the internals of models in order to get the information it needs.
é    N)ÚCounterÚ
namedtuple)ÚIteratorÚMapping)ÚchainÚcountÚproduct)Úascii_uppercase)ÚFieldDoesNotExistÚ
FieldError)ÚDEFAULT_DB_ALIASÚNotSupportedErrorÚconnections)ÚCount)Ú
LOOKUP_SEP)ÚBaseExpressionÚColÚExistsÚFÚOuterRefÚRefÚResolvedOuterRefÚValue)ÚField)ÚMultiColSource)ÚLookup)ÚQÚcheck_rel_lookup_compatibilityÚrefs_expression)ÚINNERÚLOUTERÚ	ORDER_DIRÚSINGLE)Ú	BaseTableÚEmptyÚJoinÚ	MultiJoin)ÚANDÚORÚ
ExtraWhereÚNothingNodeÚ	WhereNode)Úcached_property)Ú_lazy_re_compile)ÚNodeÚQueryÚRawQueryz['`\"\]\[;\s]|--|/\*|\*/z[\w-]+c                 ó€   — | €
t        «       S t        t        j                  d„ | j                  «       D «       «      «      S )Nc              3   ó~   K  — | ]5  }|j                   r|j                  |j                  fn|j                  f–— Œ7 y ­w©N)ÚconcreteÚnameÚattname©Ú.0Úfs     úX/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/django/db/models/sql/query.pyú	<genexpr>z,get_field_names_from_opts.<locals>.<genexpr>?   s3   è ø€ ò 
ØAB 1§:¢:ˆQ�V‰V�Q—Y‘YÑ°A·F±F°9Ó<ñ
ùs   ‚;=)Úsetr   Úfrom_iterableÚ
get_fields)Úoptss    r;   Úget_field_names_from_optsrA   ;   s=   € Ø€|Ü‹uˆÜÜ×Ññ 
ØFJÇoÁoÓFWô
ó 	
óð ó    c              #   ó  K  — t        | t        «      r| j                  –— y t        | d«      rY| j	                  «       D ]E  }t        |t        «      r|j                  –— Œ"t        |t
        «      sŒ3t        |«      E d {  –—†  ŒG y y 7 Œ­w)NÚflatten)Ú
isinstancer   r6   ÚhasattrrD   r   Úget_children_from_q)ÚexprÚchilds     r;   Úget_paths_from_expressionrJ   E   sn   è ø€ Ü�$œÔØ�i‰i‹Ü	��yÔ	!Ø—\‘\“^ò 	6ˆEÜ˜%¤Ô#Ø—j‘jÓ Ü˜E¤1Õ%Ü.¨uÓ5×5Ñ5ñ		6ð 
"ð
 6ús   ‚A.B
Á1B
Á?BÂ 	B
c              #   ó6  K  — | j                   D ]€  }t        |t        «      rt        |«      E d {  –—†  Œ't        |t        «      r*|\  }}|–— t        |d«      sŒMt        |«      E d {  –—†  Œat        |d«      sŒnt        |«      E d {  –—†  Œ‚ y 7 Œb7 Œ*7 Œ­w)NÚresolve_expression)ÚchildrenrE   r/   rG   ÚtuplerF   rJ   )ÚqrI   ÚlhsÚrhss       r;   rG   rG   P   sˆ   è ø€ Ø—‘ò 	8ˆÜ�eœTÔ"Ü*¨5Ó1×1Ñ1Ü˜œuÔ%Ø‰HˆC�ØŠIÜ�sÐ0Õ1Ü4°SÓ9×9Ñ9Ü�UÐ0Õ1Ü0°Ó7×7Ñ7ñ	8à1øð
 :øà7ús?   ‚.B°B±*BÁBÁ*BÁ+BÁ=BÂBÂBÂBÂBc           
      óÒ  — ddl m} t        |t        «      rt	        | ||«      S t        |t
        «      r]|\  }}|j                  | t        z   «      r|j                  | |d«      }t        |t        «      st        |d«      rt        | ||«      }||fS t        |t        «      rV|j                  «       }|j                  j                  | t        z   «      r"|j                  j                  | |d«      |_        |S t        ||«      rt        d«      ‚t        |d«      rH|j                  «       }|j                  |j!                  «       D �cg c]  }t        | ||«      ‘Œ c}«       |S c c}w )Nr   )ÚQuerySeté   rL   z>Passing a QuerySet within a FilteredRelation is not supported.)Údjango.db.models.queryrS   rE   r/   Úrename_prefix_from_qrN   Ú
startswithr   Úreplacer   rF   Úget_child_with_renamed_prefixÚcopyr6   Ú
ValueErrorÚset_source_expressionsÚget_source_expressions)ÚprefixÚreplacementrI   rS   rP   rQ   Úgrand_childs          r;   rY   rY   ]   sF  € Ý/ä�%œÔÜ# F¨K¸Ó?Ð?Ü�%œÔØ‰ˆˆSØ�>‰>˜&¤:Ñ-Ô.Ø—+‘+˜f k°1Ó5ˆCÜ˜#œqÔ!¤g¨cÐ3GÔ&HÜ/°¸ÀSÓIˆCØ�Cˆxˆä�%œÔØ—
‘
“ˆØ�:‰:× Ñ  ¬*Ñ!4Ô5ØŸ™×+Ñ+¨F°KÀÓCˆEŒJð" €Lô! 
�E˜8Ô	$ô
 ØLó
ð 	
ô 
�Ð,Ô	-Ø—
‘
“ˆØ×$Ñ$ð $)×#?Ñ#?Ó#Aöàô .¨f°kÀ;ÕOòô	
ð €Lùòs   ÅE$c           
      ó¨   — t        j                  |j                  D �cg c]  }t        | ||«      ‘Œ c}|j                  |j
                  «      S c c}w r4   )r   ÚcreaterM   rY   Ú	connectorÚnegated)r^   r_   rO   Úcs       r;   rV   rV   �   s@   € Ü�8‰8ØHIÏ
É
ÖSÀ1Ô	& v¨{¸AÕ	>ÒSØ	�‰Ø	�	‰	óð ùÚSs   žAÚJoinInfo)Úfinal_fieldÚtargetsr@   ÚjoinsÚpathÚtransform_functionc                   óR   — e Zd ZdZdd„Zd„ Zd„ Zd„ Zd„ Zd„ Z	e
d„ «       Zd	„ Zd
„ Zy)r1   zA single raw SQL query.c                 óv   — || _         || _        || _        d | _        d\  | _        | _        i | _        i | _        y )N©r   N)ÚparamsÚsqlÚusingÚcursorÚlow_markÚ	high_markÚextra_selectÚannotation_select)Úselfrp   rq   ro   s       r;   Ú__init__zRawQuery.__init__’   s>   € ØˆŒØˆŒØˆŒ
ØˆŒð )0Ñ%ˆŒ�t”~ØˆÔØ!#ˆÕrB   c                 ó$   — | j                  |«      S r4   )Úclone©rw   rq   s     r;   r   zRawQuery.chainž   s   € Ø�z‰z˜%Ó Ð rB   c                 óF   — t        | j                  || j                  ¬«      S )N)ro   )r1   rp   ro   r{   s     r;   rz   zRawQuery.clone¡   s   € Ü˜Ÿ™ %°·±Ô<Ð<rB   c                 óì   — | j                   €| j                  «        t        | j                     j                  j
                  }| j                   j                  D �cg c]  } ||d   «      ‘Œ c}S c c}w ©Nr   )rr   Ú_execute_queryr   rq   ÚintrospectionÚidentifier_converterÚdescription)rw   Ú	converterÚcolumn_metas      r;   Úget_columnszRawQuery.get_columns¤   sY   € Ø�;‰;ÐØ×ÑÔ!Ü §
¡
Ñ+×9Ñ9×NÑNˆ	Ø=A¿[¹[×=TÑ=TÖU¨k‘	˜+ a™.Õ)ÒUÐUùÒUs   ÁA1c                 óÞ   — | j                  «        t        | j                     j                  j                  s t        | j                  «      }t        |«      S | j                  }t        |«      S r4   )r   r   rq   ÚfeaturesÚcan_use_chunked_readsÚlistrr   Úiter)rw   Úresults     r;   Ú__iter__zRawQuery.__iter__ª   sY   € ð 	×ÑÔÜ˜4Ÿ:™:Ñ&×/Ñ/×EÒEô ˜$Ÿ+™+Ó&ˆFô �F‹|Ðð —[‘[ˆFÜ�F‹|ÐrB   c                 ó<   — d| j                   j                  ›d| ›d�S )Nú<z: ú>)Ú	__class__Ú__name__©rw   s    r;   Ú__repr__zRawQuery.__repr__¶   s   � Ø!Ÿ^™^×4Ó4²dÐ;Ð;rB   c                 óh   — | j                   €y t        | j                   t        «      rt        S t        S r4   )ro   rE   r   ÚdictrN   r’   s    r;   Úparams_typezRawQuery.params_type¹   s'   € à�;‰;ÐØÜ! $§+¡+¬wÔ7ŒtÐB¼UÐBrB   c                 ó‚   — | j                   €| j                  S | j                  | j                  | j                  «      z  S r4   )r–   rp   ro   r’   s    r;   Ú__str__zRawQuery.__str__¿   s5   € Ø×ÑÐ#Ø—8‘8ˆOØ�x‰x˜$×*Ñ*¨4¯;©;Ó7Ñ7Ð7rB   c                 óÞ  ‡— t         | j                     }| j                  }|j                  j                  Š|t
        u rt        ˆfd„| j                  D «       «      }nO|t        u r4| j                  j                  «       D ��ci c]  \  }}| ‰|«      “Œ }}}n|€d }nt        d|z  «      ‚|j                  «       | _
        | j                  j                  | j                  |«       y c c}}w )Nc              3   ó.   •K  — | ]  } ‰|«      –— Œ y ­wr4   © )r9   ÚvalÚadapters     €r;   r<   z*RawQuery._execute_query.<locals>.<genexpr>Ì   s   øè ø€ Ò?¨C™7 3Ÿ<Ñ?ùs   ƒzUnexpected params type: %s)r   rq   r–   ÚopsÚadapt_unknown_valuerN   ro   r•   ÚitemsÚRuntimeErrorrr   Úexecuterp   )rw   Ú
connectionr–   ro   Úkeyrœ   r�   s         @r;   r   zRawQuery._execute_queryÄ   sÈ   ø€ Ü  §¡Ñ,ˆ
ð ×&Ñ&ˆØ—.‘.×4Ñ4ˆØœ%ÑÜÓ?°4·;±;Ô?Ó?‰FØœDÑ Ø8<¿¹×8IÑ8IÓ8K×L©H¨C°�c™7 3›<Ñ'ÐLˆFÒLØÐ Ø‰FäÐ;¸kÑIÓJÐJà ×'Ñ'Ó)ˆŒØ�‰×Ñ˜DŸH™H fÕ-ùó Ms   ÂC)N)r›   )r‘   Ú
__module__Ú__qualname__Ú__doc__rx   r   rz   r…   rŒ   r“   Úpropertyr–   r˜   r   r›   rB   r;   r1   r1   �   sD   „ Ù!ó
$ò!ò=òVò
ò<ð ñCó ðCò
8ó
.rB   ÚExplainInfo)ÚformatÚoptionsc                   óz  — e Zd ZdZdZdZ eeg«      ZdZe	Z
eZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZd	Z dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ* e«       dfZ+dZ,ddd
„Z-e.d„ «       Z/e0d„ «       Z1d„ Z2d„ Z3d„ Z4ded„Z5d„ Z6d„ Z7dfd„Z8d„ Z9d„ Z:d„ Z;d„ Z<d„ Z=ddd„Z>d„ Z?dfd„Z@d„ ZAdfd„ZBdfd„ZCd„ ZDdgd „ZEd!„ ZFdhd"„ZGd#„ ZHd$„ ZId%„ ZJd&„ ZKdfd'„ZLd(„ ZMd)„ ZNdfd*„ZOd+„ ZPd,„ ZQddd-„ZRd.„ ZSd/„ ZTdfd0„ZUd1„ ZVdid2„ZWdid3„ZXd4„ ZYd5„ ZZd6„ Z[d7„ Z\d8„ Z]	 	 	 	 	 	 	 	 djd9„Z^d:„ Z_d;„ Z`d<„ Zad=„ Zb	 	 	 	 	 	 	 dkd>„Zcd?„ Zddld@„Ze	 	 dmdA„ZfdB„ ZgehdndC„«       ZiehdD„ «       ZjdodE„ZkdF„ ZldG„ ZmdH„ ZndpdI„ZodJ„ Zpe.dK„ «       ZqdL„ ZrdM„ ZsdN„ ZtdO„ ZudP„ ZvdQ„ ZwdR„ ZxdddS„ZydT„ ZzdndU„Z{dddV„Z|dW„ Z}dX„ Z~dY„ ZdZ„ Z€d[„ Z�d\„ Z‚d]„ Zƒd^„ Z„d_„ Z…e.d`„ «       Z†e.da„ «       Z‡db„ Zˆdc„ Z‰y)qr0   zA single SQL query.ÚTNÚSQLCompilerTFr›   r   é   c                 ó¾   — || _         i | _        i | _        || _        i | _        i | _        t        «       | _        t        «       | _	        i | _
        i | _        i | _        y r4   )ÚmodelÚalias_refcountÚ	alias_mapÚ
alias_colsÚexternal_aliasesÚ	table_mapr=   Úused_aliasesr,   ÚwhereÚannotationsÚextraÚ_filtered_relations)rw   r±   r´   s      r;   rx   zQuery.__init__$  s^   € ØˆŒ
Ø ˆÔð ˆŒà$ˆŒð
 !#ˆÔØˆŒÜ›EˆÔä“[ˆŒ
àˆÔð ˆŒ
à#%ˆÕ rB   c                 ó$  — t        | j                  «      dk(  r*| j                  d   }t        |dd «      xs |j                  S t        | j                  «      dk(  r6t        t        | j                  j                  «       «      «      j                  S y )NrT   r   Útarget)	ÚlenÚselectÚgetattrÚfieldrv   ÚnextrŠ   ÚvaluesÚoutput_field)rw   r¿   s     r;   rÄ   zQuery.output_field@  su   € äˆt�{‰{Ó˜qÒ Ø—[‘[ ‘^ˆFÜ˜6 8¨TÓ2ÒB°f·l±lÐBÜ�×'Ñ'Ó(¨AÒ-Üœ˜T×3Ñ3×:Ñ:Ó<Ó=Ó>×KÑKÐKð .rB   c                 ó,   — | j                   D ]  }|c S  y r4   )r³   ©rw   Úaliass     r;   Ú
base_tablezQuery.base_tableH  s   € à—^‘^ò 	ˆEØŠLñ	rB   c                 ó2   — | j                  «       \  }}||z  S )a(  
        Return the query as a string of SQL with the parameter values
        substituted in (use sql_with_params() to see the unsubstituted string).

        Parameter values won't necessarily be quoted correctly, since that is
        done by the database interface at execution time.
        )Úsql_with_params)rw   rp   ro   s      r;   r˜   zQuery.__str__M  s    € ð ×*Ñ*Ó,‰ˆˆVØ�V‰|ÐrB   c                 óH   — | j                  t        «      j                  «       S )zw
        Return the query as an SQL string and the parameters that will be
        substituted into the query.
        )Úget_compilerr   Úas_sqlr’   s    r;   rÊ   zQuery.sql_with_paramsX  s   € ð
 × Ñ Ô!1Ó2×9Ñ9Ó;Ð;rB   c                 óB   — | j                  «       }||t        | «      <   |S )z4Limit the amount of work when a Query is deepcopied.)rz   Úid)rw   Úmemor‹   s      r;   Ú__deepcopy__zQuery.__deepcopy___  s   € à—‘“ˆØˆŒR�‹X‰ØˆrB   c                 ó’   — |€|€t        d«      ‚|r	t        |   } |j                  j                  | j                  «      | |||«      S )NzNeed either using or connection)r[   r   rž   Úcompiler)rw   rq   r£   Úelide_emptys       r;   rÌ   zQuery.get_compilere  sP   € Øˆ=˜ZÐ/ÜÐ>Ó?Ð?ÙÜ$ UÑ+ˆJØ5ˆz�~‰~×&Ñ& t§}¡}Ó5Ø�*˜e [ó
ð 	
rB   c                 óH   — | j                   r| j                   j                  S y)z¸
        Return the Options instance (the model._meta) from which to start
        processing. Normally, this is self.model._meta, but it can be changed
        by subclasses.
        N)r±   Ú_metar’   s    r;   Úget_metazQuery.get_metan  s    € ð �:Š:Ø—:‘:×#Ñ#Ð#ð rB   c                 ó<  — t        «       }| j                  |_        | j                  j                  «       |_        | j                  j                  «       |_        | j
                  j                  «       |_        | j                  j                  «       |_        | j                  j                  «       |_        | j                  j                  «       |_        | j                  j                  «       |_
        | j                  �| j                  j                  «       |_        | j                  r6t        | j                  D �cg c]  }|j                  «       ‘Œ c}«      |_        d|_        | j                  j                  «       |_        | j                   �| j                   j                  «       |_        | j"                  �| j"                  j                  «       |_        | j$                  dur$t        j&                  |j$                  «      |_        d| j                  v r| j(                  j                  «       |_        | j*                  j                  «       |_        | j,                  j                  «       |_        |j                  j/                  dd«       |S c c}w )zf
        Return a copy of the current Query. A lightweight alternative to
        deepcopy().
        NFÚsubq_aliasesrÈ   )r%   r�   Ú__dict__rZ   r²   r³   rµ   r¶   r¸   rz   r¹   Úannotation_select_maskÚcombined_queriesrN   Ú_annotation_select_cacherº   Úextra_select_maskÚ_extra_select_cacheÚselect_relatedÚdeepcopyrÙ   r·   r»   Úpop)rw   ÚobjÚquerys      r;   rz   zQuery.clonew  sö  € ô
 ‹gˆØŸ™ˆŒà—}‘}×)Ñ)Ó+ˆŒà!×0Ñ0×5Ñ5Ó7ˆÔØŸ™×+Ñ+Ó-ˆŒØ#×4Ñ4×9Ñ9Ó;ˆÔØŸ™×+Ñ+Ó-ˆŒØ—J‘J×$Ñ$Ó&ˆŒ	Ø×*Ñ*×/Ñ/Ó1ˆŒØ×&Ñ&Ð2Ø)-×)DÑ)D×)IÑ)IÓ)KˆCÔ&Ø× Ò Ü#(Ø,0×,AÑ,AÖB 5�—‘•ÒBó$ˆCÔ ð (,ˆÔ$Ø—J‘J—O‘OÓ%ˆŒ	Ø×!Ñ!Ð-Ø$(×$:Ñ$:×$?Ñ$?Ó$AˆCÔ!Ø×#Ñ#Ð/Ø&*×&>Ñ&>×&CÑ&CÓ&EˆCÔ#Ø×Ñ eÑ+ô "&§¡¨s×/AÑ/AÓ!BˆCÔØ˜TŸ]™]Ñ*Ø#×0Ñ0×5Ñ5Ó7ˆCÔØ×,Ñ,×1Ñ1Ó3ˆÔØ"&×":Ñ":×"?Ñ"?Ó"AˆÔà�‰×Ñ˜ tÔ,Øˆ
ùò/ Cs   Ä?Jc                 óÒ   — | j                  «       }|r|j                  |k7  r||_        |j                  st        «       |_        d|_        t        |d«      r|j                  «        |S )z¤
        Return a copy of the current Query that's ready for another operation.
        The klass argument changes the type of the Query, e.g. UpdateQuery.
        FÚ_setup_query)rz   r�   Úfilter_is_stickyr=   r·   rF   ræ   )rw   Úklassrã   s      r;   r   zQuery.chain¤  sZ   € ð
 �j‰j‹lˆÙ�S—]‘] eÒ+Ø!ˆCŒMØ×#Ò#Ü"›uˆCÔØ$ˆÔÜ�3˜Ô'Ø×ÑÔØˆ
rB   c                 óH   — | j                  «       }|j                  |«       |S r4   )rz   Úchange_aliases)rw   Ú
change_maprz   s      r;   Úrelabeled_clonezQuery.relabeled_clone³  s    € Ø—
‘
“ˆØ×Ñ˜ZÔ(ØˆrB   c                 óB   — | j                   sd }|j                  ||«      S r4   ©r´   Úget_col)rw   r½   rÁ   rÇ   s       r;   Ú_get_colzQuery._get_col¸  s   € Ø�ŠØˆEØ�~‰~˜e UÓ+Ð+rB   c                 ó‚  ‡ — |si S d}d}i }‰ j                   }|j                  «       D ]Ä  \  }}‰ j                  |«       |j                  ‰ ddd¬«      }	|	j                  st        d|z  «      ‚‰ j                  |g«       |	j                  «       }
|t        ˆ fd„|
D «       «      z  }|t        ˆ fd„|
D «       «      z  }|	j                  |«      }	|	‰ j                  |<   |	|t        ||	«      <   ŒÆ |D �ci c]  }|‰ j                  j                  |«      “Œ  }}‰ j                  |«       ‰ j                  j                  «       \  }}}t        d„ ‰ j                  j!                  «       D «       «      xs |}t#        ‰ j$                  t&        «      s-‰ j(                  s!|s|s|s|s‰ j*                  s‰ j,                  �r¿d	d
lm} ‰ j3                  «       }d|_         |‰ j6                  |«      }d|_        d|_        |j                  ‰ j<                  «       |j?                  d¬«       |j*                  �s+|j@                  rE|rC‰ j6                  jB                  jD                  jG                  |jI                  «       «      f|_        d|_         |sÑ‰ j,                  sÅtK        «       }t#        ‰ j$                  t&        «      r$‰ j$                  D ]  }||j                  «       z  }Œ |j!                  «       D ]  }	||	j                  «       z  }Œ ‰ j<                  j                  «       D ]'  \  }}|jM                  «       sŒ|jO                  |«       Œ) |j                  |«       i }|j                  «       D ]›  \  }}	i }‰ jQ                  |	gd¬«      D ]_  }|jS                  |«      x}sEtU        |«      dz   }d|› �}t        ||«      }|||<   ||j                  |<   |j                  |g«       |||<   Œa |	j                  |«      |j                  |<   Œ� |jV                  dk(  �r|j@                  sû|j                   sï‰ j6                  jB                  jD                  jG                  |jI                  «       «      f|_+        n«‰ }d‰ _+        d‰ _         i ‰ _,        ‰ j                  rp‰ j                  j                  «       D ��ci c]  \  }}t        ||«      |“Œ }}}|j                  «       D ��	ci c]  \  }}	||	j                  |«      “Œ c}	}‰ _
        n|‰ _
        ‰ j                  |«       |j<                  j!                  «       D �cg c]  }|jZ                  ‘Œ }}t        d„ |D «       «       }|j?                  d¬«       |j]                  «        d|_        d|_        |j_                  ||¬«      }|ja                  tb        «      } | €|} nE|je                  |j<                  j!                  «       «      }!tg        |ji                  | f|!«      «      } tk        tm        |j<                  | «      «      S c c}w c c}}w c c}	}w c c}w )zU
        Return the dictionary with the values of the existing aggregations.
        FTN©Úallow_joinsÚreuseÚ	summarizez!%s is not an aggregate expressionc              3   óR   •K  — | ]  }t        ‰j                  |   d d«      –— Œ  y­w)Úcontains_subqueryFN©rÀ   r¹   ©r9   Úrefrw   s     €r;   r<   z(Query.get_aggregation.<locals>.<genexpr>Ô  s.   øè ø€ ò !àô ˜×(Ñ(¨Ñ-Ð/BÀE×Jñ!ùó   ƒ$'c              3   óR   •K  — | ]  }t        ‰j                  |   d d«      –— Œ  y­w)Úcontains_over_clauseTNrø   rù   s     €r;   r<   z(Query.get_aggregation.<locals>.<genexpr>Ø  s.   øè ø€ ò àô ˜×(Ñ(¨Ñ-Ð/EÀt×Lñùrû   c              3   ó6   K  — | ]  }t        |d d«      –— Œ y­w)Úcontains_aggregateTN)rÀ   )r9   Ú
annotations     r;   r<   z(Query.get_aggregation.<locals>.<genexpr>ç  s"   è ø€ ò àô ˜
Ð$8¸$×?ñùs   ‚r   )ÚAggregateQuery©Úforce)Úresolve_refsrT   Ú__colr›   c              3   ó,   K  — | ]  }|t         u –— Œ y ­wr4   )ÚNotImplemented)r9   r‹   s     r;   r<   z(Query.get_aggregation.<locals>.<genexpr>b  s   è ø€ ÒV¸6˜f¬Ô6ÑVùs   ‚)rÔ   )7rÛ   r    Úcheck_aliasrL   rÿ   Ú	TypeErrorÚappend_annotation_maskÚget_refsÚanyÚreplace_expressionsr¹   r   râ   Úset_annotation_maskr¸   Úsplit_having_qualifyrÃ   rE   Úgroup_byrN   Ú	is_slicedÚdistinctÚ
combinatorÚdjango.db.models.sql.subqueriesr  rz   Úsubqueryr±   Úselect_for_updaterà   rv   Úclear_orderingÚdefault_colsrÖ   Úpkrï   Úget_initial_aliasr=   Úget_group_by_colsÚaddÚ	_gen_colsÚgetr¾   r¿   rº   Úempty_result_set_valueÚclear_limitsrÌ   Úexecute_sqlr#   Úget_convertersrÂ   Úapply_convertersr•   Úzip)"rw   rq   Úaggregate_exprsÚrefs_subqueryÚrefs_windowÚreplacementsrÛ   rÇ   Úaggregate_exprÚ	aggregateÚaggregate_refsÚ
aggregatesÚ_ÚhavingÚqualifyÚhas_existing_aggregationr  Úinner_queryÚouter_queryÚannotation_maskrH   Úannotation_aliasr   Úcol_refsÚcolÚcol_refÚindexÚ	col_aliasÚ
expressionÚempty_set_resultrÔ   rÓ   r‹   Ú
converterss"   `                                 r;   Úget_aggregationzQuery.get_aggregation½  s9  ø€ ñ ØˆIð ˆØˆØˆØ!%×!<Ñ!<ÐØ%4×%:Ñ%:Ó%<ò 	<Ñ!ˆE�>Ø×Ñ˜UÔ#Ø&×9Ñ9Ø $¨d¸dð :ó ˆIð ×/Ò/ÜÐ CÀeÑ KÓLÐLð ×'Ñ'¨¨Ô0Ø&×/Ñ/Ó1ˆNØœSó !à)ô!ó ñ ˆMð œ3ó à)ôó ñ ˆKð "×5Ñ5°lÓCˆIØ&/ˆD×Ñ˜UÑ#Ø2;ˆLœ˜U IÓ.Ò/ð+	<ð0 GVÖV¸U�e˜T×-Ñ-×1Ñ1°%Ó8Ñ8ÐVˆ
ÐVØ× Ñ Ð!7Ô8ð "ŸZ™Z×<Ñ<Ó>Ñˆˆ6�7äñ à"&×"2Ñ"2×"9Ñ"9Ó";ôó ò ð ð 	!ô$ �t—}‘}¤eÔ,Ø�~Š~Ù'ÙÙÙØ�}Š}Ø�‹åFàŸ*™*›,ˆKØ#'ˆKÔ Ù(¨¯©°[ÓAˆKØ,1ˆKÔ)Ø).ˆKÔ&Ø×+Ñ+¨D×,BÑ,BÔCð ×&Ñ&¨UÐ&Ô3Ø×'Ó'ð ×+Ò+Ñ0HàŸ
™
×(Ñ(×+Ñ+×3Ñ3°K×4QÑ4QÓ4SÓTð,�KÔ(ð ,1�Ô(Ù t§¢ô
 '*£e�OÜ! $§-¡-´Ô7Ø$(§M¡Mò ?˜DØ+¨t¯}©}«Ñ>™Oð?à%/×%6Ñ%6Ó%8ò @˜	Ø'¨9×+=Ñ+=Ó+?Ñ?™ð@ð 9=×8NÑ8N×8TÑ8TÓ8Vò BÑ4Ð(¨*Ø%×7Ñ7Õ9Ø+×/Ñ/Ð0@ÕAðBð  ×3Ñ3°OÔDð ˆHØ$.×$4Ñ$4Ó$6ò Ñ ��yØ!�ØŸ>™>¨9¨+ÀE˜>ÓJò 0�CØ'/§|¡|°CÓ'8Ð8˜GÐ8Ü # H£°Ñ 1˜Ø&+¨E¨7 O˜	Ü"% i°Ó"5˜Ø(/˜ ™Ø=@˜×/Ñ/°	Ñ:Ø#×:Ñ:¸I¸;ÔGØ(/�L Ò%ð0ð 2;×1NÑ1NØ ó2�×'Ñ'¨Ò.ðð ×"Ñ" bÓ(Ø#×0Ò0Ø#×:Ò:ð —J‘J×$Ñ$×'Ñ'×/Ñ/°×0MÑ0MÓ0OÓPð&�Õ"ð ˆKØˆDŒKØ %ˆDÔØˆDŒJØ×Òð .2×-=Ñ-=×-CÑ-CÓ-E÷ á)˜˜zô ˜˜zÓ*¨JÑ6ð �ñ  ð -7×,<Ñ,<Ó,>÷$á(˜˜yð ˜9×8Ñ8¸ÓFÑFó$�Õ ð
 $.�Ô Ø×$Ñ$ ZÔ0ð *×;Ñ;×BÑBÓDö
àð ×-Ó-ð
Ðð 
ô ÑVÐEUÔVÓVÐVˆØ×"Ñ"¨Ð"Ô.Ø× Ñ Ô"Ø(-ˆÔ%Ø%*ˆÔ"Ø×+Ñ+¨E¸{Ð+ÓKˆØ×%Ñ%¤fÓ-ˆØˆ>Ø%‰Fà!×0Ñ0°×1NÑ1N×1UÑ1UÓ1WÓXˆJÜ˜(×3Ñ3°V°I¸zÓJÓKˆFä”C˜×5Ñ5°vÓ>Ó?Ð?ùò] Wùób ùó$ùò
s   Ã3#X+Ò;X0Ó(X6ÕX<c                 ób   — | j                  «       }|j                  |dt        d«      i«      d   S )zO
        Perform a COUNT() query using the current filter constraints.
        Ú__countÚ*)rz   r=  r   )rw   rq   rã   s      r;   Ú	get_countzQuery.get_countq  s0   € ð �j‰j‹lˆØ×"Ñ" 5¨9´e¸C³jÐ*AÓBÀ9ÑMÐMrB   c                 ó   — | j                   S r4   )r¸   r’   s    r;   Úhas_filterszQuery.has_filtersx  s   € Ø�z‰zÐrB   c                 ó  — | j                  «       }|j                  r|j                  sg|j                  du rI|j	                  d„ | j
                  j                  j                  D «       d«       |j                  d¬«       |j                  «        |j                  r0|j                  dk(  r!t        d„ |j                  D «       «      |_
        |j                  d¬«       |r|j                  d¬	«       |j                  t!        d«      d
«       |S )NTc              3   ó4   K  — | ]  }|j                   –— Œ y ­wr4   ©r7   r8   s     r;   r<   zQuery.exists.<locals>.<genexpr>€  s   è ø€ ÒI 1�Q—Y•YÑIùó   ‚F©Úallow_aliasesÚunionc              3   ó@   K  — | ]  }|j                  d ¬«      –— Œ y­w)F)ÚlimitN)Úexists)r9   Úcombined_querys     r;   r<   zQuery.exists.<locals>.<genexpr>‡  s&   è ø€ ò 'à"ð ×%Ñ%¨EÐ%×2ñ'ùs   ‚r  rT   )ÚhighÚa)rz   r  r  r  Ú
add_fieldsr±   rÖ   Úconcrete_fieldsÚset_group_byÚclear_select_clauserÜ   r  rN   r  Ú
set_limitsÚadd_annotationr   )rw   rL  rO   s      r;   rM  zQuery.exists{  sÙ   € Ø�J‰J‹LˆØ—
’
˜qŸ{š{Ø�z‰z˜TÑ!Ø—‘ÙI¨¯
©
×(8Ñ(8×(HÑ(HÔIÈ5ôð
 —‘¨U�Ô3Ø×!Ñ!Ô#Ø×Ò !§,¡,°'Ò"9Ü!&ñ 'à&'×&8Ñ&8ô'ó "ˆAÔð 	
×Ñ˜tÐÔ$ÙØ�L‰L˜aˆLÔ Ø	×Ñœ˜q› 3Ô'ØˆrB   c                 óh   — | j                  |«      }|j                  |¬«      }|j                  «       S )N©rq   )rM  rÌ   Úhas_results)rw   rq   rO   rÓ   s       r;   rY  zQuery.has_results‘  s/   € Ø�K‰K˜ÓˆØ—>‘>¨�>Ó.ˆØ×#Ñ#Ó%Ð%rB   c                 ó  — | j                  «       }|D ]*  }t        j                  |«      rd|v sŒt        d|›d�«      ‚ t	        ||«      |_        |j                  |¬«      }dj                  |j                  «       «      S )Nz--zInvalid option name: ú.rX  ú
)	rz   ÚEXPLAIN_OPTIONS_PATTERNÚ	fullmatchr[   r©   Úexplain_inforÌ   ÚjoinÚexplain_query)rw   rq   rª   r«   rO   Úoption_namerÓ   s          r;   ÚexplainzQuery.explain–  s�   € Ø�J‰J‹LˆØ"ò 	KˆKä+×5Ñ5°kÔBØ˜;Ò&ä Ð#8¸¸ÀqÐ!IÓJÐJð	Kô % V¨WÓ5ˆŒØ—>‘>¨�>Ó.ˆØ�y‰y˜×/Ñ/Ó1Ó2Ð2rB   c                 óŠ  ‡ — ‰ j                   |j                   k7  rt        d«      ‚‰ j                  rt        d«      ‚‰ j                  |j                  k7  rt        d«      ‚‰ j                  |j                  k7  rt        d«      ‚‰ j                  «       }|j                  «       }|j                  ‰ |h¬«       i }|t        k(  }|r
t        «       nt        ‰ j                  «      }t        |dd«      }|j                  ˆ fd„‰ j                  D «       «       t        «       }t        |j                  «      d	d
 }	|	D ]•  }
|j                  |
   }|j                  |«      }‰ j                  ||¬«      }|j                   t"        k(  r|j%                  |«       |j'                  |«       |
|k7  r|||
<   |j(                  |
   rŒ…‰ j+                  |«       Œ— |j                  |«       |j-                  ‰ «       ‰ xj.                  |j.                  z  c_        |j0                  j                  «       }|j3                  |«       ‰ j0                  j%                  ||«       |j4                  r9‰ j7                  |j4                  D �cg c]  }|j                  |«      ‘Œ c}«       nd‰ _        |t8        k(  r#‰ j:                  r|j:                  rt=        d«      ‚‰ j:                  j?                  |j:                  «       t        «       }‰ j@                  �|j?                  ‰ j@                  «       |j@                  �|j?                  |j@                  «       |r‰ jC                  |«       ‰ xjD                  |jD                  z  c_"        |jF                  xs ‰ jF                  ‰ _#        |jH                  xs ‰ jH                  ‰ _$        y
c c}w )aN  
        Merge the 'rhs' query into the current one (with any 'rhs' effects
        being applied *after* (that is, "to the right of") anything in the
        current query. 'rhs' is not modified during a call to this function.

        The 'connector' parameter describes how to connect filters from the
        'rhs' query.
        z4Cannot combine queries on two different base models.z3Cannot combine queries once a slice has been taken.z6Cannot combine a unique query with a non-unique query.z6Cannot combine queries with different distinct fields.)Úexcludeé   Fc              3   ód   •K  — | ]'  }‰j                   |   j                  t        k(  sŒ$|–— Œ) y ­wr4   )r³   Ú	join_typer    )r9   Újrw   s     €r;   r<   z Query.combine.<locals>.<genexpr>Ð  s,   øè ø€ ò 
Ø¨¯©¸Ñ):×)DÑ)DÌÓ)MŒAñ
ùs   ƒ%0©0rT   N©rô   r›   zSWhen merging querysets using 'or', you cannot have extra(select=...) on both sides.)%r±   r	  r  r  Údistinct_fieldsr  rz   Úbump_prefixr(   r=   r³   ÚJoinPromoterÚ	add_votesr‰   rì   r`  rh  r    r  Údiscardr²   Úunref_aliasÚupdate_join_typesrÙ   r¸   Úrelabel_aliasesr¿   Ú
set_selectr)   rº   r[   ÚupdaterÞ   Úset_extra_maskÚextra_tablesÚorder_byÚextra_order_by)rw   rQ   rc   Úinitial_aliasrë   Úconjunctionrô   ÚjoinpromoterÚ	rhs_votesÚ
rhs_tablesrÇ   r`  Ú	new_aliasÚwr6  rÞ   s   `               r;   ÚcombinezQuery.combine¢  s-  ø€ ð �:‰:˜Ÿ™Ò"ÜÐRÓSÐSØ�>Š>ÜÐQÓRÐRØ�=‰=˜CŸL™LÒ(ÜÐTÓUÐUØ×Ñ 3×#6Ñ#6Ò6ÜÐTÓUÐUð ×.Ñ.Ó0ˆØ�i‰i‹kˆØ�‰˜ } oˆÔ6ð ˆ
Ø¤3Ñ&ˆñ %””¬#¨d¯n©nÓ*=ˆÜ# I¨q°%Ó8ˆØ×Ñó 
Ø—~‘~ô
ô 	
ô “Eˆ	ô ˜#Ÿ-™-Ó(¨¨Ð,ˆ
Øò 	,ˆEØ—=‘= Ñ'ˆDð ×'Ñ'¨
Ó3ˆDØŸ	™	 $¨e˜	Ó4ˆIØ�~‰~¤Ò&Ø—‘˜iÔ(ð �M‰M˜)Ô$Ø˜	Ò!Ø$-�
˜5Ñ!Ø×%Ñ% eÓ,ð
 × Ñ  Õ+ð'	,ð( 	×Ñ˜yÔ)Ø×&Ñ& tÔ,ð 	×Ò˜S×-Ñ-Ñ-Õð �I‰I�O‰OÓˆØ	×Ñ˜*Ô%Ø�
‰
�‰�q˜)Ô$ð �:Š:Ø�O‰OÈÏ
É
ÖSÀ˜S×0Ñ0°Õ<ÒSÕTàˆDŒKàœŠ?ð �zŠz˜cŸišiÜ ð7óð ð 	�
‰
×Ñ˜#Ÿ)™)Ô$Ü›EÐØ×!Ñ!Ð-Ø×$Ñ$ T×%;Ñ%;Ô<Ø× Ñ Ð,Ø×$Ñ$ S×%:Ñ%:Ô;ÙØ×ÑÐ 1Ô2Ø×Ò˜S×-Ñ-Ñ-Õð Ÿ™Ò5¨¯©ˆŒØ!×0Ñ0ÒG°D×4GÑ4GˆÕùò5 Ts   É?O c                 óŠ  — |€i }i ||j                   <   |j                  |j                  z   D ]à  }|j                  |j                  d «      }d }t        |dd «      x}r|j                  |d «      }|€|€|j                  |i «       ŒY|sŒ\|j                  st        t        t        |«      «      «      ‚|j                  rŒ’|j                  |i «      }|j                  j                  j                  }	| j                  |	j                  ||«       Œâ |j!                  «       D ]   \  }
}| j"                  j%                  |
«      x}rm|j'                  |j(                  «      }|j                  |
|fi «      }|j                  j                  j                  }	| j                  |	j                  ||«       Œ�|j'                  |
«       Œ¢ |S )Nr7   )r  rR  Úrelated_objectsrâ   r6   rÀ   Ú
setdefaultÚis_relationr   rÂ   rŠ   Úmany_to_manyÚrelated_modelrÖ   Úconcrete_modelÚ_get_defer_select_maskr    r»   r  Ú	get_fieldÚrelation_name)rw   r@   ÚmaskÚselect_maskrÁ   Ú
field_maskÚfield_att_maskÚfield_attnameÚfield_select_maskr†  Ú
field_nameÚfiltered_relationÚrelations                r;   rˆ  zQuery._get_defer_select_mask  sº  € ØÐØˆKØ!ˆ�D—G‘GÑð
 ×)Ñ)¨D×,@Ñ,@Ñ@ò 	ˆEØŸ™ %§*¡*¨dÓ3ˆJØ!ˆNÜ '¨¨y¸$Ó ?Ð?ˆ}Ð?Ø!%§¡¨-¸Ó!>�ØÐ! nÐ&<Ø×&Ñ& u¨bÕ1ÚØ×(Ò(Ü$¤T¬$¨zÓ*:Ó%;Ó<Ð<ð ×%Ò%ØØ$/×$:Ñ$:¸5À"Ó$EÐ!Ø %× 3Ñ 3× 9Ñ 9× HÑ H�Ø×+Ñ+Ø!×'Ñ'¨Ð5Fõð'	ð0 '+§j¡j£lò 		+Ñ"ˆJ˜
Ø$(×$<Ñ$<×$@Ñ$@ÀÓ$LÐLÐ ÐLØŸ>™>Ð*;×*IÑ*IÓJ�Ø$/×$:Ñ$:¸JÈÐ;QÐSUÓ$VÐ!Ø (× 6Ñ 6× <Ñ <× KÑ K�Ø×+Ñ+Ø!×'Ñ'¨Ð5Fõð —‘˜zÕ*ð		+ð ÐrB   c                 óˆ  — |€i }i ||j                   <   |j                  «       D ]›  \  }}|j                  |«      }|j                  |i «      }|sŒ,|j                  st        t        t        |«      «      «      ‚|j                  j                  j                  j                  }| j                  |j                  ||«       Œ� |S r4   )r  r    r‰  rƒ  r„  r   rÂ   rŠ   Úremote_fieldr±   rÖ   r‡  Ú_get_only_select_mask)	rw   r@   r‹  rŒ  r‘  r�  rÁ   r�  r†  s	            r;   r–  zQuery._get_only_select_maskB  s¸   € ØÐØˆKØ!ˆ�D—G‘GÑà&*§j¡j£lò 		Ñ"ˆJ˜
Ø—N‘N :Ó.ˆEØ +× 6Ñ 6°u¸bÓ AÐÚØ×(Ò(Ü$¤T¬$¨zÓ*:Ó%;Ó<Ð<Ø %× 2Ñ 2× 8Ñ 8× >Ñ >× MÑ M�Ø×*Ñ*Ø!×'Ñ'¨Ð5Fõð		ð ÐrB   c                 ó  — | j                   \  }}|si S i }|D ]0  }|}|j                  t        «      D ]  }|j                  |i «      }Œ Œ2 | j	                  «       }|r| j                  ||«      S | j                  ||«      S )aÐ  
        Convert the self.deferred_loading data structure to an alternate data
        structure, describing the field that *will* be loaded. This is used to
        compute the columns to select from the database and also by the
        QuerySet class to work out which fields are being initialized on each
        model. Models that have all their fields included aren't mentioned in
        the result, only those that have field restrictions in place.
        )Údeferred_loadingÚsplitr   rƒ  r×   rˆ  r–  )rw   Úfield_namesÚdeferr‹  r‘  Ú	part_maskÚpartr@   s           r;   Úget_select_maskzQuery.get_select_maskS  s—   € ð "×2Ñ2Ñˆ�UÙØˆIØˆØ%ò 	;ˆJØˆIØ"×(Ñ(¬Ó4ò ;�Ø%×0Ñ0°°rÓ:‘	ñ;ð	;ð �}‰}‹ˆÙØ×.Ñ.¨t°TÓ:Ð:Ø×)Ñ)¨$°Ó5Ð5rB   c                 ó\  — | j                   j                  |«      }|s"|r |d   }| j                  |xx   dz  cc<   |dfS |r9d| j                  t	        | j
                  «      dz   fz  }|j                  |«       n |�|j                  n|}|g| j                   |<   d| j                  |<   |dfS )a  
        Return a table alias for the given table_name and whether this is a
        new alias or not.

        If 'create' is true, a new alias is always created. Otherwise, the
        most recently created alias for the table (if one exists) is reused.
        r   rT   Fú%s%dT)r¶   r  r²   Úalias_prefixr¾   r³   ÚappendrÇ   )rw   Ú
table_namerb   r’  Ú
alias_listrÇ   s         r;   Útable_aliaszQuery.table_aliasi  sÀ   € ð —^‘^×'Ñ'¨
Ó3ˆ
Ù™*Ø˜q‘MˆEØ×Ñ Ó&¨!Ñ+Ó&Ø˜%�<Ðñ Ø˜d×/Ñ/´°T·^±^Ó1DÀqÑ1HÐIÑIˆEØ×Ñ˜eÕ$ð ,=Ð+HÐ!×'Ò'Èjð ð +0¨ˆD�N‰N˜:Ñ&Ø%&ˆ×Ñ˜EÑ"Ø�dˆ{ÐrB   c                 ó2   — | j                   |xx   dz  cc<   y)z-Increases the reference count for this alias.rT   N©r²   rÆ   s     r;   Ú	ref_aliaszQuery.ref_alias„  s   € à×Ñ˜EÓ" aÑ'Ô"rB   c                 ó2   — | j                   |xx   |z  cc<   y)z-Decreases the reference count for this alias.Nr§  )rw   rÇ   Úamounts      r;   rp  zQuery.unref_aliasˆ  s   € à×Ñ˜EÓ" fÑ,Ô"rB   c                 óP  ‡ ‡‡— t        ‰«      Š‰�r‰j                  d«      Š‰ j                  ‰   j                  €Œ.‰ j                  ‰   j                  €J ‚‰ j                  ‰   j                  }|xr  ‰ j                  |   j                  t
        k(  }‰ j                  ‰   j                  t
        k(  }‰ j                  ‰   j                  s|rR|sP‰ j                  ‰   j                  «       ‰ j                  ‰<   ‰j                  ˆˆˆ fd„‰ j                  D «       «       ‰r�Œyy)a   
        Promote recursively the join type of given aliases and its children to
        an outer join. If 'unconditional' is False, only promote the join if
        it is nullable or the parent join is an outer join.

        The children promotion is done to avoid join chains that contain a LOUTER
        b INNER c. So, if we have currently a INNER b INNER c and a->b is promoted,
        then we must also promote b->c automatically, or otherwise the promotion
        of a->b doesn't actually change anything in the query results.
        r   Nc              3   ób   •K  — | ]&  }‰j                   |   j                  ‰k(  r|‰vr|–— Œ( y ­wr4   )r³   Úparent_alias)r9   r`  rÇ   Úaliasesrw   s     €€€r;   r<   z&Query.promote_joins.<locals>.<genexpr>ª  s8   øè ø€ ò àØ—~‘~ dÑ+×8Ñ8¸EÒAØ GÑ+ô ñùs   ƒ,/)	r‰   râ   r³   rh  r­  r!   ÚnullableÚpromoteÚextend)rw   r®  r­  Úparent_louterÚalready_louterrÇ   s   ``   @r;   Úpromote_joinszQuery.promote_joinsŒ  sý   ú€ ô �w“-ˆÚØ—K‘K “NˆEØ�~‰~˜eÑ$×.Ñ.Ð6ð à—>‘> %Ñ(×2Ñ2Ð>Ð>Ð>ØŸ>™>¨%Ñ0×=Ñ=ˆLàÒQ §¡°Ñ!=×!GÑ!GÌ6Ñ!Qð ð "Ÿ^™^¨EÑ2×<Ñ<ÄÑFˆNØ—‘˜uÑ%×.Ò.±-ÉØ(,¯©°uÑ(=×(EÑ(EÓ(G�—‘˜uÑ%ð —‘õ à $§¡ôô õ% rB   c                 óp  — t        |«      }|r©|j                  d«      }| j                  |   j                  t        k(  rt| j                  |   j                  «       | j                  |<   | j                  |   j                  }| j                  |   j                  t        k(  r|j                  |«       |rŒ¨yy)a¹  
        Change join type from LOUTER to INNER for all joins in aliases.

        Similarly to promote_joins(), this method must ensure no join chains
        containing first an outer, then an inner join are generated. If we
        are demoting b->c join in chain a LOUTER b LOUTER c then we must
        demote a->b automatically, or otherwise the demotion of b->c doesn't
        actually change anything in the query results. .
        r   N)	r‰   râ   r³   rh  r!   Údemoter­  r    r¢  )rw   r®  rÇ   r­  s       r;   Údemote_joinszQuery.demote_joins±  s�   € ô �w“-ˆÙØ—K‘K “NˆEØ�~‰~˜eÑ$×.Ñ.´&Ò8Ø(,¯©°uÑ(=×(DÑ(DÓ(F�—‘˜uÑ%Ø#Ÿ~™~¨eÑ4×AÑA�Ø—>‘> ,Ñ/×9Ñ9¼UÒBØ—N‘N <Ô0ô rB   c                 ó²   — | j                   j                  «       j                  «       D ],  \  }}||j                  |d«      z
  }| j	                  ||«       Œ. y)zp
        Reset reference counts for aliases so that they match the value passed
        in `to_counts`.
        r   N)r²   rZ   r    r  rp  )rw   Ú	to_countsrÇ   Úcur_refcountÚunref_amounts        r;   Úreset_refcountszQuery.reset_refcountsÄ  sU   € ð
 $(×#6Ñ#6×#;Ñ#;Ó#=×#CÑ#CÓ#Eò 	2ÑˆE�<Ø'¨)¯-©-¸¸qÓ*AÑAˆLØ×Ñ˜U LÕ1ñ	2rB   c                 óˆ  — |s| S t        |«      j                  |j                  «       «      sJ ‚| j                  j	                  |«       t        | j                  t        «      r7t        | j                  D �cg c]  }|j                  |«      ‘Œ c}«      | _        t        | j                  D �cg c]  }|j                  |«      ‘Œ c}«      | _	        | j                  xr= | j                  j                  «       D ��ci c]  \  }}||j                  |«      “Œ c}}| _
        |j                  «       D ]¯  \  }}|| j                  vrŒ| j                  |   j                  |«      }|| j                  |<   | j                  |   | j                  |<   | j                  |= | j                  |= | j                  |j                     }t!        |«      D ]  \  }}	|	|k(  sŒ|||<    Œ¯ Œ± | j"                  j                  «       D �	�
ci c]  \  }	}
|j%                  |	|	«      |
xs |	|v “Œ  c}
}	| _        yc c}w c c}w c c}}w c c}
}	w )z²
        Change the aliases in change_map (which maps old-alias -> new-alias),
        relabelling any references to them in select columns and the where
        clause.
        N)r=   Ú
isdisjointrÃ   r¸   rr  rE   r  rN   rì   r¿   r¹   r    r³   r²   r¶   r£  Ú	enumeraterµ   r  )rw   rë   r6  r¤   Ú	old_aliasr~  Ú
alias_dataÚtable_aliasesÚposrÇ   Úaliaseds              r;   rê   zQuery.change_aliasesÍ  s  € ñ ØˆKô �:‹×)Ñ)¨*×*;Ñ*;Ó*=Ô>Ð>Ð>ð 	�
‰
×"Ñ" :Ô.Ü�d—m‘m¤UÔ+Ü!Ø<@¿M¹MÖJ°S�×$Ñ$ ZÕ0ÒJóˆDŒMô ÈÏÉÖTÀ˜S×0Ñ0°Õ<ÒTÓUˆŒØ×+Ñ+ò 
à ×,Ñ,×2Ñ2Ó4÷1
á��Sð �×$Ñ$ ZÓ0Ñ0ó1
ˆÔð %/×$4Ñ$4Ó$6ò 	Ñ ˆI�yØ §¡Ñ.ØØŸ™¨	Ñ2×BÑBÀ:ÓNˆJØ(2ˆD�N‰N˜9Ñ%Ø-1×-@Ñ-@ÀÑ-KˆD×Ñ 	Ñ*Ø×#Ñ# IÐ.Ø—‘˜yÐ)à ŸN™N¨:×+@Ñ+@ÑAˆMÜ'¨Ó6ò ‘
��UØ˜IÓ%Ø)2�M #Ñ&Ùñð	ð" #'×"7Ñ"7×"=Ñ"=Ó"?÷!
ñ ��wð �N‰N˜5 %Ó(¨7Ò+I°e¸zÐ6IÑIó!
ˆÕùò/ KùâTùó1
ùó(!
s   Á7H.Â.H3Ã=H8È#H>c           
      óD  ‡ — ˆ fd„}‰ j                   |j                   k7  ryt        j                  «       dz  }t         |«       «      D ],  \  }}|‰ j                  vr	|‰ _          n||kD  sŒ#t        d«      ‚ ‰ j                  j                  ‰ j                   g«      ‰ _        |j                  j                  ‰ j                  «      |_        |€i }‰ j                  t        ‰ j                  «      D ��ci c]  \  }}||vr|d‰ j                   |fz  “Œ c}}«       yc c}}w )a;  
        Change the alias prefix to the next letter in the alphabet in a way
        that the other query's aliases and this query's aliases will not
        conflict. Even tables that previously had no alias will get an alias
        after this call. To prevent changing aliases use the exclude parameter.
        c               3   ó  •K  — t         } t        t        ‰j                  «      dz   «      }|–— t	        d«      D ]A  }|r| | j                  |«      d n| }t        ||¬«      D ]  }dj                  |«      –— Œ d}ŒC y­w)a  
            Generate a sequence of characters in alphabetical order:
                -> 'A', 'B', 'C', ...

            When the alphabet is finished, the sequence will continue with the
            Cartesian product:
                -> 'AA', 'AB', 'AC', ...
            rT   N)ÚrepeatÚ )r
   ÚchrÚordr¡  r   r8  r	   r`  )Úalphabetr^   ÚnÚseqÚsrw   s        €r;   Ú
prefix_genz%Query.bump_prefix.<locals>.prefix_gen  sƒ   øè ø€ ô 'ˆHÜœ˜T×.Ñ.Ó/°!Ñ3Ó4ˆFØŠLÜ˜1“Xò �Ù<B�h˜xŸ~™~¨fÓ5Ð7Ñ8È�Ü  ¨QÔ/ò %�AØŸ'™' !›*Ó$ð%à‘ñ	ùs   ƒA<A?Né   z6Maximum recursion depth exceeded: too many subqueries.r   )	r¡  ÚsysÚgetrecursionlimitr¿  rÙ   ÚRecursionErrorrJ  rê   r³   )rw   Úother_queryre  rÏ  Úlocal_recursion_limitrÃ  r^   rÇ   s   `       r;   rl  zQuery.bump_prefixü  s%  ø€ ô	ð$ ×Ñ × 8Ñ 8Ò8àô !$× 5Ñ 5Ó 7¸2Ñ =ÐÜ$¡Z£\Ó2ò 	‰KˆC�Ø˜T×.Ñ.Ñ.Ø$*�Ô!ÙØÐ*Ó*Ü$ØLóð ð	ð !×-Ñ-×3Ñ3°T×5FÑ5FÐ4GÓHˆÔØ#.×#;Ñ#;×#AÑ#AÀ$×BSÑBSÓ#TˆÔ Øˆ?ØˆGØ×Ñô #,¨D¯N©NÓ";÷á�C˜Ø Ñ'ð �v ×!2Ñ!2°CÐ 8Ñ8Ñ8óõ	
ùós   Ã3 D
c                 óî   — | j                   r| j                  }| j                  |«       |S | j                  r;| j	                  | j                  | j                  «       j                  d«      «      }|S d}|S )zf
        Return the first alias for this query, after increasing its reference
        count.
        N)r³   rÈ   r¨  r±   r`  Úbase_table_classr×   Údb_tablerÆ   s     r;   r  zQuery.get_initial_alias3  sj   € ð
 �>Š>Ø—O‘OˆEØ�N‰N˜5Ô!ð
 ˆð	 �ZŠZØ—I‘I˜d×3Ñ3°D·M±M³O×4LÑ4LÈdÓSÓTˆEð ˆð ˆEØˆrB   c                 ót   — t        | j                  j                  «       D �cg c]  }|sŒd‘Œ	 c}«      S c c}w )zÛ
        Return the number of tables in this query with a non-zero reference
        count. After execution, the reference counts are zeroed, so tables
        added in compiler will not be seen by this method.
        rT   )r¾   r²   rÃ   )rw   r   s     r;   Úcount_active_tableszQuery.count_active_tablesA  s.   € ô  4×#6Ñ#6×#=Ñ#=Ó#?ÖI˜%Â5’AÒIÓJÐJùÒIs   ¢5ª5c                 ó4  — | j                   j                  «       D ��cg c]  \  }}|�||v r||k(  r|‘Œ }}}|r3|j                  |v r|j                  }n|d   }| j                  |«       |S | j                  |j                  d|j
                  ¬«      \  }}|j                  rJ| j                   |j                     j                  t        k(  s|j                  rt        }	nt        }	|	|_        ||_        || j                   |<   |j
                  x}
r€|}|�t        |«      |hz  }t        | j                   «      }|
j                  | |¬«      |_        |t        | j                   «      k  r(| j                   j                  |«      | j                   |<   |S c c}}w )a+  
        Return an alias for the 'join', either reusing an existing alias for
        that join or creating a new one. 'join' is either a base_table_class or
        join_class.

        The 'reuse' parameter can be either None which means all joins are
        reusable, or it can be a set containing the aliases that can be reused.

        A join is always created as LOUTER if the lhs alias is LOUTER to make
        sure chains like t1 LOUTER t2 INNER t3 aren't generated. All new
        joins are created as LOUTER if the join is nullable.
        éÿÿÿÿT)rb   r’  rj  )r³   r    r¥  r¨  r£  r’  rh  r­  r!   r¯  r    r=   r¾   rL   râ   )rw   r`  rô   rP  ri  Úreuse_aliasesÚreuse_aliasrÇ   r-  rh  r’  Úresolve_reuseÚ	joins_lens                r;   r`  z
Query.joinI  s’  € ð Ÿ™×,Ñ,Ó.÷
á��1Ø�  e¡°°d²ò ð
ˆñ 
ñ
 Ø×Ñ =Ñ0Ø"×.Ñ.‘ð ,¨BÑ/�Ø�N‰N˜;Ô'ØÐð ×#Ñ#Ø�O‰O D¸D×<RÑ<Rð $ó 
‰ˆˆqð �>Š>Ø�~‰~˜d×/Ñ/Ñ0×:Ñ:¼fÒDÈÏÊÜ"‘	ä!�	Ø&ˆDŒNØ ˆÔØ $ˆ�‰�uÑØ $× 6Ñ 6Ð6ÐÐ6Ø!ˆMØÐ(Ü # E£
¨e¨WÑ 4�Ü˜DŸN™NÓ+ˆIØ%6×%IÑ%IØ˜Mð &Jó &ˆDÔ"ð
 œ3˜tŸ~™~Ó.Ò.Ø(,¯©×(:Ñ(:¸5Ó(A�—‘˜uÑ%ØˆùóO
s   žFc                 ód  — ||v r||   S |j                  |«      }|s|S |}|D ]ƒ  }||v r|j                  }||   }Œ|j                  |   s|j                  }Œ5|j                  |«      }| j	                  |j
                  g||«      }	|j                  }|	j                  d   x}||<   Œ… |xs |d   S )a}  
        Make sure the given 'model' is joined in the query. If 'model' isn't
        a parent of 'opts' or if it is None this method is a no-op.

        The 'alias' is the root alias for starting the join, 'seen' is a dict
        of model -> alias of existing joins. It must also contain a mapping
        of None -> some alias. This will be returned in the no-op case.
        rÜ  N)Úget_base_chainrÖ   ÚparentsÚget_ancestor_linkÚsetup_joinsr6   ri   )
rw   r@   r±   rÇ   Úseenr   Ú	curr_optsÚ	int_modelÚ
link_fieldÚ	join_infos
             r;   Újoin_parent_modelzQuery.join_parent_model  sÖ   € ð �D‰=Ø˜‘;ÐØ×#Ñ# EÓ*ˆÙØˆLØˆ	Øò 	:ˆIØ˜DÑ Ø%ŸO™O�	Ø˜Y™�Øð
 ×$Ñ$ YÒ/Ø%ŸO™O�	ØØ"×4Ñ4°YÓ?ˆJØ×(Ñ(¨*¯/©/Ð):¸IÀuÓMˆIØ!Ÿ™ˆIØ&/§o¡o°bÑ&9Ð9ˆE�D˜’Oð	:ð  Ò"˜˜T™
Ð"rB   c                 óD   — t         j                  |«      rt        d«      ‚y )NzbColumn aliases cannot contain whitespace characters, quotation marks, semicolons, or SQL comments.)ÚFORBIDDEN_ALIAS_PATTERNÚsearchr[   rÆ   s     r;   r  zQuery.check_alias   s'   € Ü"×)Ñ)¨%Ô0Üð/óð ð 1rB   c                 ó
  ‡— | j                  ‰«       |j                  | dd¬«      }|r| j                  ‰g«       n9ˆfd„t        j	                  | j
                  «      D «       }| j                  |«       || j                  ‰<   y)z0Add a single annotation expression to the Query.TN)ró   rô   c              3   ó,   •K  — | ]  }|‰k7  r|–— Œ y ­wr4   r›   )r9   ÚvaluerÇ   s     €r;   r<   z'Query.add_annotation.<locals>.<genexpr>®  s    øè ø€ ò àØ˜E’>ô ñùs   ƒ)r  rL   r
  r•   Úfromkeysrv   r  r¹   )rw   r   rÇ   r¿   r3  s     `  r;   rV  zQuery.add_annotation§  sz   ø€ à×Ñ˜ÔØ×2Ñ2°4ÀTÐQUÐ2ÓVˆ
ÙØ×'Ñ'¨¨Õ0óä!Ÿ]™]¨4×+AÑ+AÓBôˆOð
 ×$Ñ$ _Ô5Ø",ˆ×Ñ˜ÒrB   c           
      óV  — | j                  «       }|j                  |«       d|_         |j                  j                  |g|¢­i |¤Ž |j
                  r<t        |j                  D �cg c]  } |j                  |g|¢­i |¤Ž‘Œ c}«      |_        |j                  j                  «       D ][  \  }} |j                  |g|¢­i |¤Ž}t        |d«      r%|j                  j                  |j                  «       ||j                  |<   Œ] |j                  j                  «       D ]~  \  }	}
t        |
t        «      xr- |
j                   j"                  j$                  j&                  |	k7  xs+ t        |
t(        «      xr |
j*                  |
j,                  k7  |j                  |	<   Œ€ |S c c}w )NTrµ   )rz   rl  r  r¸   rL   r  rN   rÜ   r¹   r    rF   rµ   rt  r³   rE   r&   Ú
join_fieldr†  rÖ   rØ  r$   r£  r¥  )rw   rä   ÚargsÚkwargsrz   rN  r¤   rñ  ÚresolvedrÇ   Útables              r;   rL   zQuery.resolve_expression¶  s•  € Ø—
‘
“ˆà×Ñ˜%Ô ØˆŒØ&ˆ�‰×&Ñ& uÐ>¨tÒ>°vÒ>à×ÒÜ%*ð +0×*@Ñ*@öà&ð 6�N×5Ñ5°eÐM¸dÒMÀfÓMòó&ˆEÔ"ð  ×+Ñ+×1Ñ1Ó3ò 	.‰JˆC�Ø/�u×/Ñ/°ÐG¸ÒGÀÑGˆHÜ�xÐ!3Ô4Ø×)Ñ)×0Ñ0°×1GÑ1GÔHØ%-ˆE×Ñ˜cÒ"ð		.ð "ŸO™O×1Ñ1Ó3ò 	‰LˆE�5ä˜5¤$Ó'ò KØ×$Ñ$×2Ñ2×8Ñ8×AÑAÀUÑJò-ô ˜5¤)Ó,ÒV°×1AÑ1AÀU×EVÑEVÑ1Vð	 ×"Ñ" 5Ò)ð	ð ˆùò%s   Á(F&c                 óî   — t        | j                  j                  «       | j                  j                  «      }| j                  |d¬«      D �cg c]  }|j                  | j                  v r|‘Œ c}S c c}w )NT)Úinclude_external)r   r¹   rÃ   r¸   rM   r  rÇ   rµ   )rw   Úexprsr6  s      r;   Úget_external_colszQuery.get_external_colsÓ  sh   € Ü�d×&Ñ&×-Ñ-Ó/°·±×1DÑ1DÓEˆð —~‘~ e¸d�~ÓCö
àØ�y‰y˜D×1Ñ1Ñ1ò ò
ð 	
ùò 
s   Á!A2c                 óX   — | j                  «       }t        d„ |D «       «      r|xs | gS |S )Nc              3   ó4   K  — | ]  }|j                   –— Œ y ­wr4   )Úpossibly_multivalued)r9   r6  s     r;   r<   z*Query.get_group_by_cols.<locals>.<genexpr>á  s   è ø€ ÒA¨Cˆs×'Õ'ÑAùrG  )rü  r  )rw   ÚwrapperÚexternal_colss      r;   r  zQuery.get_group_by_colsÛ  s3   € ð
 ×.Ñ.Ó0ˆÜÑA°=ÔAÔAØ’O˜tÐ$Ð$ØÐrB   c                 ó   — | j                   rK|j                  j                  s5| j                  d¬«       | j                  D ]  }|j                  d¬«       Œ | j                  |¬«      j                  «       \  }}| j                   rd|z  }||fS )NFr  )r£   z(%s))r  r‡   Ú*ignores_unnecessary_order_by_in_subqueriesr  rÜ   rÌ   rÍ   )rw   rÓ   r£   rä   rp   ro   s         r;   rÍ   zQuery.as_sqlå  s‹   € ð �MŠMØ×'Ñ'×RÒRà×Ñ eÐÔ,Ø×.Ñ.ò 2�Ø×$Ñ$¨5Ð$Õ1ð2à×'Ñ'°:Ð'Ó>×EÑEÓG‰ˆˆVØ�=Š=Ø˜3‘,ˆCØ�Fˆ{ÐrB   c                 óä   ‡ ‡‡‡— t        |d«      r|j                  ‰ ‰‰‰¬«      }|S t        |t        t        f«      r2ˆˆˆ ˆfd„|D «       }t        |«      }t        |d«      r ||Ž S  ||«      S |S )NrL   )rô   ró   rõ   c              3   óF   •K  — | ]  }‰j                  |‰‰‰«      –— Œ y ­wr4   )Úresolve_lookup_value)r9   Ú	sub_valueró   Ú	can_reuserw   rõ   s     €€€€r;   r<   z-Query.resolve_lookup_value.<locals>.<genexpr>ÿ  s*   øè ø€ ò àð ×)Ñ)¨)°YÀÈY×Wñùs   ƒ!Ú_make)rF   rL   rE   r‰   rN   Útype)rw   rñ  r  ró   rõ   rÃ   Útype_s   ` ```  r;   r  zQuery.resolve_lookup_valueô  sƒ   û€ Ü�5Ð.Ô/Ø×,Ñ,ØØØ'Ø#ð	 -ó ˆEð" ˆô ˜¤¤e˜}Ô-öà!&ôˆFô ˜“KˆEÜ�u˜gÔ&Ù˜f�~Ð%Ù˜“=Ð ØˆrB   c                 óÎ  — |j                  t        «      }| j                  r=t        || j                  «      \  }}|r"| j                  |   }|rt	        ||«      }|d|fS | j                  || j                  «       «      \  }}}}	|dt        |«      t        |	«      z
   }
t        |	«      dkD  r6|
s4t        d|›d| j                  «       j                  j                  ›d�«      ‚|	|
dfS )zX
        Solve the lookup type from the lookup (e.g.: 'foobar__id__icontains').
        r›   r   rT   zInvalid lookup "z" for model ú".F)r™  r   r¹   r   r   Únames_to_pathr×   r¾   r   r±   r‘   )rw   Úlookuprõ   Úlookup_splittedr   Úexpression_lookupsr:  r-  rÁ   Úlookup_partsÚfield_partss              r;   Úsolve_lookup_typezQuery.solve_lookup_type	  sê   € ð !Ÿ,™,¤zÓ2ˆØ×ÒÜ-<Ø ×!1Ñ!1ó.Ñ*ˆJÐ*ñ Ø!×-Ñ-¨jÑ9�
ÙÜ!$ Z°Ó!<�JØ)¨2¨zÐ9Ð9Ø$(×$6Ñ$6°ÈÏÉËÓ$XÑ!ˆˆ5�!�\Ø% a¬#¨oÓ*>ÄÀ\ÓARÑ*RÐSˆÜˆ|Ó˜qÒ ©Ýâ˜4Ÿ=™=›?×0Ñ0×9Ó9ð;óð ð ˜[¨%Ð/Ð/rB   c                 ó˜   — t        |d«      r>t        |j                  j                  ||«      st	        d|›d|j
                  ›d�«      ‚yy)z˜
        Check whether the object passed while querying is of the correct type.
        If not, raise a ValueError specifying the wrong object.
        rÖ   zCannot query "z": Must be "z" instance.N)rF   r   rÖ   r±   r[   Úobject_name)rw   rñ  r@   rÁ   s       r;   Úcheck_query_object_typezQuery.check_query_object_type   sL   € ô
 �5˜'Ô"Ü1°%·+±+×2CÑ2CÀTÈ5ÔQÝ â˜d×.Ó.ð0óð ð Rð #rB   c                 ó†  — |j                   rµt        |t        «      r]|j                  sQt	        |j
                  ||«      s:t        d|j
                  j                  j                  ›d|j                  ›d�«      ‚t        |d«      r| j                  |||«       yt        |d«      r|D ]  }| j                  |||«       Œ yyy)z3Check the type of object passed to query relations.zCannot use QuerySet for "z": Use a QuerySet for "r  rÖ   rŒ   N)r„  rE   r0   Úhas_select_fieldsr   r±   r[   rÖ   r  rF   r  )rw   rÁ   rñ  r@   Úvs        r;   Úcheck_related_objectszQuery.check_related_objects,  s³   € à×Òô ˜5¤%Ô(Ø×/Ò/Ü6°u·{±{ÀDÈ%ÔPå à—{‘{×(Ñ(×4Ó4°d×6FÓ6FðHóð ô ˜ Ô(Ø×,Ñ,¨U°D¸%Õ@Ü˜ 
Ô+Øò A�AØ×0Ñ0°°D¸%Õ@ñAð ,ð# rB   c                 óà   — t        |d«      r/t        |dd«      s"t        |j                  j                  dz   «      ‚t        |d«      r'|j                  «       D ]  }| j                  |«       Œ yy)z>Raise an error if expression cannot be used in a WHERE clause.rL   Ú
filterableTz$ is disallowed in the filter clause.r]   N)rF   rÀ   r   r�   r‘   r]   Úcheck_filterable)rw   r:  rH   s      r;   r  zQuery.check_filterableC  s{   € ä�:Ð3Ô4¼WØ˜ dô>
ô $Ø×$Ñ$×-Ñ-ð 1ñ óð ô �:Ð7Ô8Ø"×9Ñ9Ó;ò ,�Ø×%Ñ% dÕ+ñ,ð 9rB   c                 óì  — |xs dg�^ }}|D ]  }| j                  ||«      }Œ |j                  |«      }|s(| j                  ||«      }d}|j                  |«      }|sy |||«      }|j                  €3|j                  s'|dvrt	        d«      ‚ |j                  d«      |d«      S |dk(  rH|j                  dk(  r9t
        t           j                  j                  r |j                  d«      |d«      S |S )a1  
        Try to extract transforms and lookup from given lhs.

        The lhs value is something that works like SQLExpression.
        The rhs value is what the lookup is going to compare against.
        The lookups is a list of names to extract using get_lookup()
        and get_transform().
        ÚexactN)r   Úiexactz Cannot use None as a query valueÚisnullTrÈ  )	Útry_transformÚ
get_lookuprQ   Úcan_use_none_as_rhsr[   r   r   r‡   Ú!interprets_empty_strings_as_nulls)	rw   ÚlookupsrP   rQ   Ú
transformsÚlookup_namer6   Úlookup_classr  s	            r;   Úbuild_lookupzQuery.build_lookupP  s  € ð $+Ò#7¨w¨iÑ ˆ�[Øò 	0ˆDØ×$Ñ$ S¨$Ó/‰Cð	0ð —~‘~ kÓ2ˆÙð ×$Ñ$ S¨+Ó6ˆCØ!ˆKØŸ>™>¨+Ó6ˆLÙØá˜c 3Ó'ˆð �:‰:Ð f×&@Ò&@ØÐ"5Ñ5Ü Ð!CÓDÐDØ+�3—>‘> (Ó+¨C°Ó6Ð6ð ˜7Ò"Ø—
‘
˜bÒ ÜÔ,Ñ-×6Ñ6×XÒXà+�3—>‘> (Ó+¨C°Ó6Ð6àˆrB   c                 ó.  — |j                  |«      }|r ||«      S |j                  j                  }t        j                  ||j                  j                  «       «      }|rddj                  |«      z  }nd}t        d|›d|j                  ›d|›�«      ‚)z€
        Helper method for build_lookup(). Try to fetch and initialize
        a transform for name parameter from lhs.
        z, perhaps you meant %s?z or r[  zUnsupported lookup 'z' for z# or join on the field not permitted)	Úget_transformrÄ   r�   ÚdifflibÚget_close_matchesÚget_lookupsr`  r   r‘   )rw   rP   r6   Útransform_classrÄ   Úsuggested_lookupsÚ
suggestions          r;   r#  zQuery.try_transform~  s–   € ð
 ×+Ñ+¨DÓ1ˆÙÙ" 3Ó'Ð'à×+Ñ+×5Ñ5ˆLÜ '× 9Ñ 9Ø�c×&Ñ&×2Ñ2Ó4ó!Ðñ !Ø6¸¿¹ÐEVÓ9WÑW‘
à �
Ýâ!% |×'<Ó'<¹jðJóð rB   c
                 ó¼	  — t        |t        «      rt        d«      ‚t        |t        «      r| j	                  |||||||||	¬«	      S t        |d«      ret        |dd«      st        d«      ‚|j                  | |||¬«      }
t        |
t        «      s| j                  dg|
d	«      }
t        |
gt        ¬
«      g fS |\  }}|st        d|z  «      ‚| j                  ||«      \  }}}|r| j                  |«       |st        |«      dkD  rt        d«      ‚| j                   j#                  «       }| j%                  ||||«      }| j                   j'                  «       D ��ch c]  \  }}||j)                  |d«      kD  sŒ|’Œ }}}|r| j                  |«       |r'| j                  |||«      }
t        |
gt        ¬
«      g fS | j+                  «       }| j-                  «       }| xs | }	 | j/                  |||||¬«      }t        |t0        «      rt3        |«      }| j5                  |j6                  ||j8                  «       |j:                  | _        |jE                  |j:                  «       | jG                  |jH                  |j:                  |jJ                  «      \  }}}|�|jE                  |«       |j6                  jL                  rRt        |«      dk(  r!| jO                  |d   |j6                  |«      }nCtQ        |||jH                  |j6                  «      }n | jO                  |d   |j6                  |«      }| j                  |||«      }
|
jR                  }t        |
gt        ¬
«      }|dk(  xr |
jT                  d	u xr | }|�r|dk7  s|
jT                  du �r|
jT                  �õd	}|dk7  rî| jW                  |d   «      s#| jX                  |d      jZ                  t\        k(  rT|d   j_                  d«      }| jO                  |d   |jH                  d   |«      }|ja                   ||d«      t        «       t        |tb        «      rS| jW                  |jd                  «      r8|jd                  j_                  d«      }|ja                   ||d«      t        «       ||s|fS dfS c c}}w # t>        $ r'}| jA                  |||jB                  «      cY d}~S d}~ww xY w)a/  
        Build a WhereNode for a single filter clause but don't add it
        to this Query. Query.add_q() will then add this filter to the where
        Node.

        The 'branch_negated' tells us if the current branch contains any
        negations. This will be used to determine if subqueries are needed.

        The 'current_negated' is used to determine if the current filter is
        negated or not and this will be used to determine if IS NULL filtering
        is needed.

        The difference between current_negated and branch_negated is that
        branch_negated is set on first negation, but current_negated is
        flipped for each negation.

        Note that add_filter will not do any negating itself, that is done
        upper in the code by add_q().

        The 'can_reuse' is a set of reusable joins for multijoins.

        The method will create a filter clause that can be added to the current
        query. However, if the filter isn't added to the query then the caller
        is responsible for unreffing the joins used.
        z"Cannot parse keyword query as dict)Úbranch_negatedÚcurrent_negatedr·   ró   Ú
split_subqr  rõ   rq  rL   ÚconditionalFz3Cannot filter against a non-conditional expression.rò   r   T)rc   zCannot parse keyword query %rrT   ú7Joined field references are not permitted in this queryr   )r  Ú
allow_manyNr"  rÜ  r›   )3rE   r•   r   r   Ú_add_qrF   rÀ   r	  rL   r   r+  r,   r(   r  r  r¾   r²   rZ   r  r    r  r×   r  rå  r   r‰   r  rg   r@   ri   Ú_lookup_joinsr'   Úsplit_excludeÚnames_with_pathrt  Ú
trim_joinsrh   rj   r„  rð   r   r)  rQ   Úis_nullabler³   rh  r!   r$  r  r   r½   ) rw   Úfilter_exprr5  r6  r  ró   r7  r  rõ   rq  Ú	conditionÚargrñ  r'  ÚpartsÚreffed_expressionÚ	pre_joinsÚkr  Ú
used_joinsr@   rÇ   r:  rê  Úerh   Ú	join_listr6  Úlookup_typeÚclauseÚrequire_outerr*  s                                    r;   Úbuild_filterzQuery.build_filter”  s½  € ôJ �k¤4Ô(ÜÐAÓBÐBÜ�k¤1Ô%Ø—;‘;ØØ-Ø /Ø&Ø'Ø%Ø!1Ø#Ø"3ð ó 
ð 
ô �;Ð 4Ô5Ü˜;¨°uÔ=ÜÐ UÓVÐVØ#×6Ñ6Ø +°YÈ)ð 7ó ˆIô ˜i¬Ô0Ø ×-Ñ-¨w¨i¸ÀDÓI�	Ü˜i˜[´CÔ8¸"Ð<Ð<Ø ‰
ˆˆUÙÜÐ<¸sÑBÓCÐCØ,0×,BÑ,BÀ3È	Ó,RÑ)ˆ�Ð)áØ×!Ñ!Ð"3Ô4áœs 5›z¨Aš~ÜÐVÓWÐWà×'Ñ'×,Ñ,Ó.ˆ	Ø×)Ñ)¨%°¸KÈÓSˆà×-Ñ-×3Ñ3Ó5÷
Ù�!�Q¸¸Y¿]¹]È1ÈaÓ=PÓ9PŠAð
ˆ
ñ 
ñ Ø×!Ñ! %Ô(áØ×)Ñ)¨'Ð3DÀeÓLˆIÜ˜i˜[´CÔ8¸"Ð<Ð<à�}‰}‹ˆØ×&Ñ&Ó(ˆØ'Ð'Ò9¨z¨>ˆ
ð	QØ×(Ñ(ØØØØ#Ø%ð )ó ˆIô ˜%¤Ô*Ü˜U›�Ø×&Ñ& y×'<Ñ'<¸eÀYÇ^Á^ÔTð "+§¡ˆDÔð 	×Ñ˜)Ÿ/™/Ô*Ø$(§O¡OØ×Ñ˜yŸ™°	·±ó%
Ñ!ˆ�˜	ð Ð Ø×Ñ˜YÔ'à× Ñ ×,Ò,Ü�7‹|˜qÒ Ø—m‘m G¨A¡J°	×0EÑ0EÀuÓM‘ä$Ø˜7 I×$5Ñ$5°y×7LÑ7Ló‘ð —-‘- ¨¡
¨I×,AÑ,AÀ5ÓIˆCà×%Ñ% g¨s°EÓ:ˆ	Ø×+Ñ+ˆÜ˜I˜;´#Ô6ˆð ˜8Ñ#ÒU¨	¯©¸Ð(=ÒUÀoÐBUð 	ò Ø Ò(¨I¯M©M¸UÒ,BØ—‘Ð)à ˆMØ˜hÒ&ð ×$Ñ$ W¨Q¡ZÔ0Ø—~‘~ i°¡mÑ4×>Ñ>Ä&ÒHà#*¨1¡:×#8Ñ#8¸Ó#B�LØŸ-™-¨°©
°I×4EÑ4EÀaÑ4HÈ%ÓP�CØ—J‘J™|¨C°Ó7¼Ô=ô ˜e¤SÔ)¨d×.>Ñ.>¸u¿|¹|Ô.LØ#(§<¡<×#:Ñ#:¸8Ó#D�LØ—J‘J™|¨E°5Ó9¼3Ô?Ø©�zÐ>Ð>¸BÐ>Ð>ùós
øô@ ò 	QØ×%Ñ% k°9¸a×>OÑ>OÓPÕPûð	Qús+   ÅR%Å9R%Ç%A)R+ Ò+	SÒ4SÓSÓSc                 ó<   — | j                  t        ||f«      «       y r4   )Úadd_qr   )rw   Ú
filter_lhsÚ
filter_rhss      r;   Ú
add_filterzQuery.add_filter8  s   € Ø�
‰
”1�j *Ð-Ó.Õ/rB   c                 ó&  — | j                   D �ch c]%  }| j                   |   j                  t        k(  sŒ$|’Œ' }}| j                  || j                  «      \  }}|r | j
                  j                  |t        «       | j                  |«       yc c}w )zo
        A preprocessor for the internal _add_q(). Responsible for doing final
        join promotion.
        N)	r³   rh  r    r;  r·   r¸   r  r(   r·  )rw   Úq_objectrP  Úexisting_innerrL  r-  s         r;   rP  zQuery.add_q;  s|   € ð —~‘~ö
Ø¨¯©¸Ñ):×)DÑ)DÌÓ)MŠAð
ˆð 
ð —K‘K ¨$×*;Ñ*;Ó<‰	ˆ�ÙØ�J‰J�N‰N˜6¤3Ô'Ø×Ñ˜.Õ)ùò
s
   �%BµBc                 ó.   — | j                  |d¬«      d   S )NF)ró   r   )rN  )rw   rA  s     r;   Úbuild_wherezQuery.build_whereN  s   € Ø× Ñ  ¸%Ð Ó@ÀÑCÐCrB   c                 ó"   — t        «       | _        y r4   )r,   r¸   r’   s    r;   Úclear_wherezQuery.clear_whereQ  s   € Ü“[ˆ�
rB   c
                 ó¼  — |j                   }
||j                  z  }|xs |j                  }t        |
|j                  ¬«      }t        |j                   t	        |j
                  «      |«      }|j
                  D ]E  }| j                  |||||||||	¬«	      \  }}|j                  |«       |sŒ4|j                  ||
«       ŒG |	r|j                  | «      }||fS g }||fS )z%Add a Q-object to the current filter.)rc   rd   )r  r5  r6  ró   r7  r  rõ   rq  )
rc   rd   r,   rm  r¾   rM   rN  rn  r  rq  )rw   rU  r·   r5  r6  ró   r7  r  rõ   rq  rc   Útarget_clauser{  rI   Úchild_clauseÚneeded_inners                   r;   r;  zQuery._add_qT  s  € ð ×&Ñ&ˆ	Ø˜8×+Ñ+Ñ+ˆØ'Ò;¨8×+;Ñ+;ˆÜ!¨I¸x×?OÑ?OÔPˆÜ#Ø×Ñ¤ H×$5Ñ$5Ó 6¸ó
ˆð ×&Ñ&ò 	;ˆEØ)-×):Ñ):ØØ&Ø-Ø /Ø'Ø%Ø!1Ø#Ø"3ð *;ó 
*Ñ&ˆL˜,ð ×"Ñ" <Ô0ÚØ×!Ñ! ,°	Õ:ð	;ñ Ø'×9Ñ9¸$Ó?ˆLð ˜lÐ*Ð*ð ˆLØ˜lÐ*Ð*rB   c           	      ó:  — ||_         | j                  |j                  «      \  }}}|rt        d|j                  z  «      ‚t	        |j
                  «      D ]„  }| j                  |«      \  }}}|sdnd}	|d |	  }
t        |
«      D ]S  \  }}t        |«      |kD  r%||   |k7  sŒt        d|j                  ›d|›d�«      ‚t        d|›d|j                  ›d�«      ‚ Œ† t        |j                  ||j
                  «      |_        || j                  |j                   <   y )	NzAFilteredRelation's relation_name cannot contain lookups (got %r).rf  rT   zCFilteredRelation's condition doesn't support relations outside the z (got z).zaFilteredRelation's condition doesn't support nested relations deeper than the relation_name (got z for )
rÇ   r  rŠ  r[   rG   rB  r¿  r¾   rV   r»   )rw   r’  rÇ   Úrelation_lookup_partsÚrelation_field_partsr-  r  r  Úlookup_field_partsÚshiftÚlookup_field_pathÚidxÚlookup_field_parts                r;   Úadd_filtered_relationzQuery.add_filtered_relation}  sX  € Ø"'ÐÔØ9=×9OÑ9OØ×+Ñ+ó:
Ñ6ÐÐ3°Qñ !ÜðØ/×=Ñ=ñ>óð ô *Ð*;×*EÑ*EÓFò 	ˆFØ26×2HÑ2HÈÓ2PÑ/ˆLÐ,¨aÙ)‘A¨qˆEØ 2°7°U°FÐ ;ÐÜ*3Ð4EÓ*Fò Ñ&�Ð&ÜÐ+Ó,¨sÒ2Ø+¨CÑ0Ð4EÓEÝ(ð  1×>Ó>ÂðHóð õ %ò #)Ð*;×*IÓ*IðKóð ñð		ô$ ';Ø×+Ñ+ØØ×'Ñ'ó'
ÐÔ#ð
 =Nˆ× Ñ Ð!2×!8Ñ!8Ò9rB   c           	      óÂ  — g g }}t        |«      D �][  \  }}|g f}	|dk(  r|�|j                  j                  }d}
d}	 |€t        ‚|j	                  |«      }
|
�H|
j                  r|
j                  st        d|z  «      ‚	 |
j                   j"                  j$                  }n]|dz  }|dk(  s|rNt)        g t+        |«      ¢| j
                  ¢| j                  ¢«      }t        d|›dd	j-                  |«      ›�«      ‚ �nr|�U||j                   urG|j/                  |«      }|r4|j                  |«       |	d   j                  |«       |d   j0                  }t3        |
d
«      rÜ|r|
j5                  |«      }n|
j6                  }|sYt        |«      D ]K  \  }}|j8                  sŒ|	d   j                  |d|dz    «       |j;                  |	«       t=        |dz   |«      ‚ |d   }|j                  |«       |j>                  }|j0                  }|j@                  }|	d   j                  |«       |j;                  |	«       �Œ,|
}|
f}|r)|dz   tC        |«      k7  rt        d||dz      ›d|›d�«      ‚ n ||dz   d fS # t        $ rÈ || j
                  v r| j
                  |   j                  }
nœ|| j                  v rŽ|dk(  r‰| j                  |   }t        |j                  v rM|j                  j                  t        «      }| j                  ||||«      \  }}
}}|j                  |dd «       n|j	                  |j                  «      }
Y �Œõw xY w# t&        $ r d}Y �Œ`w xY w)aì  
        Walk the list of names and turns them into PathInfo tuples. A single
        name in 'names' can generate multiple PathInfos (m2m, for example).

        'names' is the path of names to travel, 'opts' is the model Options we
        start the name resolving from, 'allow_many' is as for setup_joins().
        If fail_on_missing is set to True, then a name that can't be resolved
        will generate a FieldError.

        Return a list of PathInfo tuples. In addition return the final field
        (the last used join field) and target (which is a field guaranteed to
        contain the same value as the final field). Finally, return those names
        that weren't found (which are likely transforms and the final lookup).
        r  Nr   rÜ  z¬Field %r does not generate an automatic reverse relation and therefore cannot be used for reverse querying. If it is a GenericForeignKey, consider adding a GenericRelation.rT   zCannot resolve keyword 'z' into field. Choices are: ú, Ú
path_infosúCannot resolve keyword z into field. Join on 'z' not permitted.)"r¿  r  r6   r   r‰  rv   rÄ   r»   r   rŠ  r™  r  r±  r„  r†  r   r±   rÖ   r‡  ÚAttributeErrorÚsortedrA   r`  Úget_path_to_parentÚto_optsrF   Úget_path_inforj  Úm2mr¢  r'   rô  Útarget_fieldsr¾   )rw   Únamesr@   r:  Úfail_on_missingrj   r>  rÃ  r6   Úcur_names_with_pathrÁ   r’  rD  Úfiltered_relation_pathr-  r±   Ú	availableÚpath_to_parentÚ	pathinfosÚ	inner_posÚpÚlastrg   rh   s                           r;   r  zQuery.names_to_path   sÀ  € ð !# BˆoˆÜ" 5Ó)ó a	‰IˆC�Ø#'¨ *ÐØ�tŠ| Ð 0Ø—w‘w—|‘|�àˆEØ $ÐðPØ�<Ü+Ð+ØŸ™ tÓ,�ð" Ð ð ×$Ò$¨U×-@Ò-@Ü$ð4ð 7;ñ;óð ð!Ø!ŸK™K×-Ñ-×<Ñ<‘Eð �q‘�Ø˜"’9¡Ü &ðÜ6°tÓ<ðà!×3Ñ3ðð "×5Ñ5ðó!�Iõ %â-1°4·9±9¸YÔ3GðIóð ò ð Ð E°·±Ñ$;Ø!%×!8Ñ!8¸Ó!?�Ù!Ø—K‘K Ô/Ø'¨Ñ*×1Ñ1°.ÔAØ)¨"Ñ-×5Ñ5�DÜ�u˜lÔ+Ù$Ø %× 3Ñ 3Ð4EÓ F‘Ià %× 0Ñ 0�IÙ!Ü(1°)Ó(<ò F™˜	 1ØŸ5›5Ø/°Ñ2×9Ñ9¸)ÀAÈ	ÐTUÉÐ:VÔWØ+×2Ñ2Ð3FÔGÜ"+¨C°!©G°_Ó"EÐEð	Fð
 ! ‘}�Ø—‘˜IÔ&Ø"Ÿo™o�Ø—|‘|�Ø×,Ñ,�Ø# AÑ&×-Ñ-¨iÔ8Ø×&Ñ&Ð':Ö;ð $�Ø ˜(�Ù" s¨Q¡w´#°e³*Ò'<Ý$à-2°3¸±7«^ºTðCóð ñ ðCa	ðD �[ '¨5°°q±°Ð+;Ð;Ð;øôo %ò PØ˜4×1Ñ1Ñ1Ø ×2Ñ2°4Ñ8×EÑE‘EØ˜T×5Ñ5Ñ5¸#Àº(Ø(,×(@Ñ(@ÀÑ(FÐ%Ü!Ð%6×%DÑ%DÑDØ 1× ?Ñ ?× EÑ EÄjÓ Q˜Ø>B×>PÑ>PØ!Ø Ø&Ø+ó	?Ñ;Ð.°°q¸!ð Ÿ™Ð$:¸3¸BÐ$?Õ@à $§¡Ð/@×/NÑ/NÓ O˜úðPûô: &ò !ð !“Eð!ús$   ½I;Á? MÉ;CMÍMÍMÍMc           
      ó  ‡ ‡‡— |g}ˆ fd„}dŠt        t        |«      dd«      D ]&  }	 ‰ j                  |d| ||d¬«      \  }	Š}
}||d } n D ](  }ˆˆˆ fd„}t	        j
                  |||¬	«      }d|_        Œ* 	D ]Ó  }|j                  r'|j                  j                  «       }|j                  }nd}d}|j                  }|j                  r‰ j                  |j                  «      }nd}‰ j                  |j                  ||t         |j                  ||¬
«      }|j"                  r|nd}‰ j%                  ||¬«      }|j'                  |«       ŒÕ t)        ‰
|||	|«      S # t        $ r}|dk(  r‚ |ŠY d}~�ŒUd}~ww xY w)a‚  
        Compute the necessary table joins for the passage through the fields
        given in 'names'. 'opts' is the Options class for the current model
        (which gives the table we are starting from), 'alias' is the alias for
        the table to start the joining from.

        The 'can_reuse' defines the reverse foreign key joins we can reuse. It
        can be None in which case all joins are reusable or a set of aliases
        that can be reused. Note that non-reverse foreign keys are always
        reusable when using setup_joins().

        If 'allow_many' is False, then any reverse foreign key seen will
        generate a MultiJoin exception.

        Return the final field involved in the joins, the target field (used
        for any 'where' constraint), the final 'opts' value, the joins, the
        field path traveled to generate the joins, and a transform function
        that takes a field and alias and is equivalent to `field.get_col(alias)`
        in the simple case but wraps field transforms if they were included in
        names.

        The target field is the field containing the concrete value. Final
        field can be something different, for example foreign key pointing to
        that value. Final field is needed for example in some value
        conversions (convert 'obj' in fk__id=obj to pk val using the foreign
        key field for example).
        c                 óB   •— ‰j                   sd }| j                  |«      S r4   rî   )rÁ   rÇ   rw   s     €r;   Úfinal_transformerz,Query.setup_joins.<locals>.final_transformer=  s   ø€ Ø—?’?Ø�Ø—=‘= Ó'Ð'rB   Nr   rÜ  T)rt  rT   c                ó€   •— 	  || |«      }‰j                  ||«      S # t        $ r t        ‰t        «      r‰r‰‚‚ w xY wr4   )r#  r   rE   r   )rÁ   rÇ   r6   ÚpreviousÚwrappedrg   Úlast_field_exceptionrw   s        €€€r;   Ú	transformz$Query.setup_joins.<locals>.transform[  sL   ø€ ðÙ& u¨eÓ4�GØ×-Ñ-¨g°tÓ<Ð<øÜ!ò ä! +¬uÔ5Ñ:NØ2Ð2àðús   ƒ ž=)r6   r�  )r’  rj  )Úranger¾   r  r   Ú	functoolsÚpartialÚhas_transformsr’  rz   rÇ   ro  Údirectr@  rô  Ú
join_classrØ  r    rq  r`  r¢  rf   )rw   rs  r@   rÇ   r  r:  ri   r  Úpivotrj   rh   Úrestr(  Úexcr6   r„  r`  r’  r¥  r¯  r£   rô   rg   rƒ  s   `                     @@r;   rå  zQuery.setup_joins  sÀ  ú€ ðF �ˆô	(ð  $ÐÜœ3˜u›: q¨"Ó-ò 	ˆEðØ37×3EÑ3EØ˜&˜5�MØØØ$(ð	 4Fó 4Ñ0��k 7¨Dð  # 5 6˜]�
Ùð'	ð( ò 	4ˆDö	ô !*× 1Ñ 1Ø Ð/@ô!Ðð 04ÐÕ,ð!	4ð( ò 	 ˆDØ×%Ò%Ø$(×$:Ñ$:×$@Ñ$@Ó$BÐ!Ø/×5Ñ5‘à$(Ð!Ø"�Ø—<‘<ˆDØ�{Š{Ø×+Ñ+¨D¯O©OÓ<‘à�ØŸ™Ø—‘ØØÜØ—‘ØØ"3ð )ó ˆJð "&§¢‘I¨tˆEØ—I‘I˜j°�IÓ6ˆEØ�L‰L˜Õð/	 ô0 ˜ W¨d°E¸4ÐARÓSÐSøôq ò /Ø˜A’:ð à+.Ö(ûð/ús   ¨E"Å"	E>Å+E9Å9E>c                 óp  ‡
— |dd }t        t        |«      «      D �]  \  }}t        |«      dk(  s|j                  s nã|j                  r nÕ|j
                  j                  D �ch c]  }|j                  ’Œ }}|D �ch c]  }|j                  ’Œ }}|j                  |«      s n||j
                  j                  D �	ci c]&  }	|	d   j                  |v r|	d   j                  |	d   “Œ( c}	Š
t        ˆ
fd„|D «       «      }| j                  |j                  «       «       �Œ ||d   |fS c c}w c c}w c c}	w )aâ  
        The 'target' parameter is the final field being joined to, 'joins'
        is the full list of join aliases. The 'path' contain the PathInfos
        used to create the joins.

        Return the final target field and table alias and the new active
        joins.

        Always trim any direct join if the target column is already in the
        previous table. Can't trim reverse joins as it's unknown if there's
        anything on the other side of the join.
        NrT   r   c              3   ó<   •K  — | ]  }‰|j                      –— Œ y ­wr4   )Úcolumn)r9   ÚtÚtargets_dicts     €r;   r<   z#Query.trim_joins.<locals>.<genexpr>£  s   øè ø€ ÒD°q˜L¨¯©Õ2ÑDùs   ƒrÜ  )r¿  Úreversedr¾   r‰  r’  rô  Úforeign_related_fieldsr�  ÚissubsetÚrelated_fieldsrN   rp  râ   )rw   rh   ri   rj   rÃ  Úinfor‘  Újoin_targetsÚcur_targetsÚrr’  s             @r;   r?  zQuery.trim_joins‡  s  ø€ ð ‘a�ˆÜ"¤8¨D£>Ó2ó 	*‰IˆC�Ü�5‹z˜QŠ d§k¢kÙØ×%Ò%ÙØ.2¯o©o×.TÑ.TÖU¨˜AŸH›HÐUˆLÐUØ-4Ö5¨˜1Ÿ8›8Ð5ˆKÐ5Ø×'Ñ'¨Ô5Ùð Ÿ™×7Ñ7öàØ�Q‘4—;‘; +Ñ-ð �!‘—‘˜Q˜q™TÑ!òˆLô
 ÓD¸GÔDÓDˆGØ×Ñ˜UŸY™Y›[Ö)ð	*ð  ˜˜b™	 5Ð(Ð(ùò VùÚ5ùòs   Á$D)Á=D.Â=+D3c              #   óB  K  — |D ]’  }t        |t        «      r|–— Œ|r/t        t        |dd «      «      r|j	                  «       E d {  –—†  ŒIt        |d«      sŒV|st        |t        «      rŒi| j                  |j                  «       ||¬«      E d {  –—†  Œ” y 7 ŒR7 Œ	­w)Nrü  r]   )rú  r  )	rE   r   ÚcallablerÀ   rü  rF   r   r  r]   )Úclsrû  rú  r  rH   s        r;   r  zQuery._gen_cols§  s¡   è ø€ àò 	ˆDÜ˜$¤Ô$Ø“
Ù!¤hÜ˜Ð1°4Ó8ô'ð  ×1Ñ1Ó3×3Ñ3Ü˜Ð7Õ8Ù#¬
°4¼Ô(=ØØŸ=™=Ø×/Ñ/Ó1Ø%5Ø!-ð )ó ÷ ñ ñ	ð 4øðús*   ‚ABÁBÁ	BÁ8BÂBÂBÂBc              #   óP   K  — d„ | j                  |«      D «       E d {  –—†  y 7 Œ­w)Nc              3   ó4   K  — | ]  }|j                   –— Œ y ­wr4   )rÇ   )r9   rH   s     r;   r<   z)Query._gen_col_aliases.<locals>.<genexpr>»  s   è ø€ Ò@ 4�D—J•JÑ@ùrG  )r  )r�  rû  s     r;   Ú_gen_col_aliaseszQuery._gen_col_aliases¹  s   è ø€ á@¨3¯=©=¸Ó+?Ô@×@Ò@ús   ‚&ž$Ÿ&c                 ó^  — | j                   j                  |«      }|�z|s?| j                  |g«      D ]*  }t        | j                  |   t
        «      sŒ!t        d«      ‚ |r5|| j                  vrt        d|z  «      ‚t        || j                  |   «      S |S |j                  t        «      }| j                   j                  |d   «      }|�|dd  D ]  }| j                  ||«      }Œ |S | j                  || j                  «       | j                  «       |¬«      }	| j                  |	j                   |	j"                  |	j$                  «      \  }
}}|st'        |«      dkD  rt        d«      ‚t'        |
«      dkD  rt        d«      ‚|	j)                  |
d   |«      }|�|j+                  |«       |S )Nr9  zCCannot aggregate over the '%s' alias. Use annotate() to promote it.r   rT   )r  z?Referencing multicolumn fields with F() objects isn't supported)r¹   r  r   rE   r³   r&   r   rv   r   r™  r   r#  rå  r×   r  r?  rh   ri   rj   r¾   rk   rt  )rw   r6   ró   rô   rõ   r   rÇ   Ú
field_listr„  rê  rh   Úfinal_aliasrJ  s                r;   Úresolve_refzQuery.resolve_ref½  sÔ  € Ø×%Ñ%×)Ñ)¨$Ó/ˆ
ØÐ!ÙØ!×2Ñ2°J°<Ó@ò �EÜ! $§.¡.°Ñ"7¼Õ>Ü(ØUóð ðñ
 ð
 ˜t×5Ñ5Ñ5Ü$ð)Ø+/ñ0óð ô ˜4 ×!7Ñ!7¸Ñ!=Ó>Ð>à!Ð!àŸ™¤JÓ/ˆJØ×)Ñ)×-Ñ-¨j¸©mÓ<ˆJØÐ%Ø!+¨A¨B ò K�IØ!%×!3Ñ!3°JÀ	Ó!J‘JðKà!Ð!Ø×(Ñ(Ø˜DŸM™M›O¨T×-CÑ-CÓ-EÐQVð )ó ˆIð /3¯o©oØ×!Ñ! 9§?¡?°I·N±Nó/Ñ+ˆG�[ )ñ ¤3 y£>°AÒ#5Ü ØMóð ô �7‹|˜aÒÜ ØUóð ð
 "×4Ñ4°W¸Q±ZÀÓMˆIØÐ Ø—‘˜YÔ'ØÐrB   c                 ó>  — | j                  | j                  «      }| j                  |_        |\  }}t        |t        «      rt	        |«      }n%t        |t
        «      rt	        |j                  «      }|j                  ||«       |j                  d¬«       |j                  |«      \  }}|j                  d   }	|	j                  }
|	j                  }||v r°|
j                  j                  j                  }|j                  | «       |
j!                  d«      } ||j#                  |j                  d   j                  «      |j#                  |«      «      }|j$                  j'                  |t(        «       d|j*                  |<   nC|
j!                  d«      } ||	t-        |«      «      }|j$                  j'                  |t(        «       | j/                  t1        |«      «      \  }}|r3| j/                  d|z  dfdd|¬«      \  }}|j'                  |t2        «       ||fS )aÄ  
        When doing an exclude against any kind of N-to-many relation, we need
        to use a subquery. This method constructs the nested query, given the
        original exclude filter (filter_expr) and the portion up to the first
        N-to-many relation field.

        For example, if the origin filter is ~Q(child__name='foo'), filter_expr
        is ('child__name', 'foo') and can_reuse is a set of joins usable for
        filters in the original query.

        We will turn this into equivalent of:
            WHERE NOT EXISTS(
                SELECT 1
                FROM child
                WHERE name = 'foo' AND child.parent_id = parent.id
                LIMIT 1
            )
        Tr  r   r   z
%s__isnull)r6  r5  r  )r�   r±   r»   rE   r   r   r6   rS  r  Ú
trim_startr¿   r½   rÇ   rÖ   r  rl  r$  rï   r¸   r  r(   rµ   r   rN  r   r)   )rw   rA  r  r>  rä   rQ  rR  Útrimmed_prefixÚcontains_louterr6  Úselect_fieldrÇ   r  r*  r  rB  r^  Úor_null_conditionr-  s                      r;   r=  zQuery.split_excludeï  sà  € ð( —‘˜tŸz™zÓ*ˆØ$(×$<Ñ$<ˆÔ!Ø!,Ñˆ
�JÜ�j¤(Ô+Ü! *Ó-‰JÜ˜
¤AÔ&Ü! *§/¡/Ó2ˆJØ×Ñ˜ ZÔ0Ø×Ñ 4ÐÔ(ð +0×*:Ñ*:¸?Ó*KÑ'ˆ˜à�l‰l˜1‰oˆØ—z‘zˆØ—	‘	ˆØ�IÑØ×#Ñ#×)Ñ)×,Ñ,ˆBð ×Ñ˜dÔ#Ø'×2Ñ2°7Ó;ˆLñ " "§*¡*¨U¯\©\¸!©_×-BÑ-BÓ"CÀRÇZÁZÐPUÓEVÓWˆFØ�K‰K�O‰O˜F¤CÔ(Ø,0ˆE×"Ñ" 5Ò)à'×2Ñ2°7Ó;ˆLÙ! #Ô'7¸Ó'GÓHˆFØ�K‰K�O‰O˜F¤CÔ(à"&×"3Ñ"3´F¸5³MÓ"BÑˆ	�<áØ#'×#4Ñ#4Ø Ñ.°Ð5Ø $Ø#Ø#ð	 $5ó $Ñ Ð˜qð �M‰MÐ+¬RÔ0ð ˜,Ð&Ð&rB   c                 ó–   — | j                   j                  t        «       t        «       | j                  D ]  }|j                  «        Œ y r4   )r¸   r  r+   r(   rÜ   Ú	set_empty)rw   rä   s     r;   r¬  zQuery.set_empty4  s5   € Ø�
‰
�‰”{“}¤cÔ*Ø×*Ñ*ò 	ˆEØ�O‰OÕñ	rB   c                 óN   — t        d„ | j                  j                  D «       «      S )Nc              3   ó<   K  — | ]  }t        |t        «      –— Œ y ­wr4   )rE   r+   )r9   re   s     r;   r<   z!Query.is_empty.<locals>.<genexpr>:  s   è ø€ ÒK°!”:˜a¤×-ÑKùs   ‚)r  r¸   rM   r’   s    r;   Úis_emptyzQuery.is_empty9  s   € ÜÑK°t·z±z×7JÑ7JÔKÓKÐKrB   c                 ó„  — |�I| j                   �)t        | j                   | j                  |z   «      | _         n| j                  |z   | _         |�I| j                   �)t        | j                   | j                  |z   «      | _        n| j                  |z   | _        | j                  | j                   k(  r| j                  «        yy)a‡  
        Adjust the limits on the rows retrieved. Use low/high to set these,
        as it makes it more Pythonic to read and write. When the SQL query is
        created, convert them to the appropriate offset and limit values.

        Apply any limits passed in here to the existing constraints. Add low
        to the current low value and clamp both to any existing high value.
        N)rt   Úminrs   r¬  )rw   ÚlowrO  s      r;   rU  zQuery.set_limits<  s˜   € ð ÐØ�~‰~Ð)Ü!$ T§^¡^°T·]±]ÀTÑ5IÓ!J�•à!%§¡°Ñ!5�”Øˆ?Ø�~‰~Ð)Ü # D§N¡N°D·M±MÀCÑ4GÓ H�•à $§¡°Ñ 3�”à�=‰=˜DŸN™NÒ*Ø�N‰NÕð +rB   c                 ó"   — d\  | _         | _        y)zClear any existing limits.rn   N©rs   rt   r’   s    r;   r   zQuery.clear_limitsS  s   € à(/Ñ%ˆŒ�t•~rB   c                 ó@   — | j                   dk7  xs | j                  d uS r~   r´  r’   s    r;   r  zQuery.is_slicedW  s   € à�}‰} Ñ!Ò? T§^¡^¸4Ð%?Ð?rB   c                 óZ   — | j                   d uxr | j                   | j                  z
  dk(  S )NrT   )rt   rs   r’   s    r;   Úhas_limit_onezQuery.has_limit_one[  s)   € Ø�~‰~ TÐ)ÒS¨t¯~©~ÀÇÁÑ/MÐRSÑ.SÐSrB   c                 ó   — | j                    S )z¥
        Return True if adding filters to this instance is still possible.

        Typically, this means no limits or offsets have been put on the results.
        )r  r’   s    r;   Ú
can_filterzQuery.can_filter^  s   € ð —>‘>Ð!Ð!rB   c                 ór   — d| _         d| _        d| _        | j                  d«       | j	                  d«       y)z%Remove all fields from SELECT clause.r›   FN)r¿   r  rà   ru  r  r’   s    r;   rT  zQuery.clear_select_clausef  s5   € àˆŒØ!ˆÔØ#ˆÔØ×Ñ˜BÔØ× Ñ  Õ$rB   c                 ó    — d| _         d| _        y)z°
        Clear the list of fields to select (but not extra_select columns).
        Some queryset types completely replace any existing list of select
        columns.
        r›   N©r¿   Úvalues_selectr’   s    r;   Úclear_select_fieldszQuery.clear_select_fieldsn  s   € ð ˆŒØˆÕrB   c                 ó\   — | xj                   |fz  c_         | xj                  |fz  c_        y r4   r¼  )rw   r6  r6   s      r;   Úadd_select_colzQuery.add_select_colw  s%   € Ø�Š˜�vÑ�Ø×Ò˜t˜gÑ%ÖrB   c                 ó2   — d| _         t        |«      | _        y )NF)r  rN   r¿   )rw   Úcolss     r;   rs  zQuery.set_select{  s   € Ø!ˆÔÜ˜D“kˆ�rB   c                 ó    — || _         d| _        y)zW
        Add and resolve the given fields to the query's "distinct on" clause.
        TN)rk  r  )rw   rš  s     r;   Úadd_distinct_fieldszQuery.add_distinct_fields  s   € ð  +ˆÔØˆ�rB   c           	      ó–  — | j                  «       }| j                  «       }	 g }|D ]‡  }| j                  |j                  t        «      |||¬«      }| j                  |j                  |j                  |j                  «      \  }}	}
|D ]#  }|j                  |j                  ||	«      «       Œ% Œ‰ |r| j                  |«       yy# t        $ r t        dz  «      ‚t        $ rd t        v r‚ t        g t        |«      ¢| j                   ¢| j"                  ¢| j$                  ¢«      }t        d|›ddj'                  |«      ›�«      ‚w xY w)zu
        Add the given (model) fields to the select set. Add the field names in
        the order specified.
        )r:  zInvalid field name: '%s'rk  z into field. Choices are: ri  N)r  r×   rå  r™  r   r?  rh   ri   rj   r¢  rk   rs  r'   r   rm  rA   rº   rv   r»   r`  )rw   rš  Ú	allow_m2mrÇ   r@   rÂ  r6   rê  rh   r£  ri   r½   rs  s                r;   rQ  zQuery.add_fields†  sr  € ð
 ×&Ñ&Ó(ˆØ�}‰}‹ˆð$	ØˆDØ#ò S�ð !×,Ñ,Ø—J‘JœzÓ*¨D°%ÀIð -ó �	ð /3¯o©oØ×%Ñ%Ø—O‘OØ—N‘Nó/Ñ+�˜ eð
 &ò S�FØ—K‘K 	× <Ñ <¸VÀ[Ó QÕRñSðSñ Ø—‘ Õ%ð øäò 	@ÜÐ7¸$Ñ>Ó?Ð?Üò 	Ü˜TÑ!ð äðÜ2°4Ó8ðàŸ™ðð ×/Ñ/ðð ×1Ñ1ð	ó�õ !â)-¨t¯y©y¸Ô/?ðAóð ð	ús   ¢B!C ÃBEc                 óú  — g }|D ]Å  }t        |t        «      r{|dk(  rŒ|j                  d«      }|| j                  v rŒ9| j                  r|| j                  v rŒT| j                  |j                  t        «      | j                  j                  «       nt        |d«      s|j                  |«       t        |dd«      sŒ¹t        d|z  «      ‚ |rt        d|z  «      ‚|r| xj                  |z  c_        yd| _        y)	a8  
        Add items from the 'ordering' sequence to the query's "order by"
        clause. These items are either field names (not column names) --
        possibly with a direction prefix ('-' or '?') -- or OrderBy
        expressions.

        If 'ordering' is empty, clear all ordering from the query.
        ú?ú-rL   rÿ   Fz[Using an aggregate in order_by() without also including it in annotate() is not allowed: %szInvalid order_by arguments: %sN)rE   ÚstrÚremoveprefixr¹   rº   r  r™  r   r±   rÖ   rF   r¢  rÀ   r   rw  Údefault_ordering)rw   ÚorderingÚerrorsÚitems       r;   Úadd_orderingzQuery.add_ordering´  sõ   € ð ˆØò 	ˆDÜ˜$¤Ô$Ø˜3’;ØØ×(Ñ(¨Ó-�Ø˜4×+Ñ+Ñ+ØØ—:’: $¨$¯*©*Ñ"4Øð ×"Ñ" 4§:¡:¬jÓ#9¸4¿:¹:×;KÑ;KÕLÜ˜TÐ#7Ô8Ø—‘˜dÔ#Ü�tÐ1°5Õ9Ü ð:Ø<@ñAóð ð	ñ& ÜÐ=ÀÑFÓGÐGÙØ�MŠM˜XÑ%ŽMà$)ˆDÕ!rB   c                 ó‚   — |s%| j                   s| j                  s| j                  ryd| _        d| _        |rd| _        yy)a  
        Remove any ordering settings if the current query allows it without
        side effects, set 'force' to True to clear the ordering regardless.
        If 'clear_default' is True, there will be no ordering in the resulting
        query (not even the model's default).
        Nr›   F)r  rk  r  rw  rx  rÌ  )rw   r  Úclear_defaults      r;   r  zQuery.clear_orderingØ  s@   € ñ Ø�NŠN˜d×2Ò2°d×6LÒ6LàØˆŒØ ˆÔÙØ$)ˆDÕ!ð rB   c                 ó€  — |r§| j                   r›i }i }t        | j                   | j                  «      D ]   \  }}t        |t        «      r|||<   Œ|||<   Œ" i |¥| j
                  ¥| _        | j                  |«       t        |j                  «       «      | _        t        |«      | _         t        | j                  «      }| j                  j                  «       D ]S  \  }}|j                  «       x}sŒ|r(|j                  s|j                  t        ||«      «       ŒC|j!                  |«       ŒU t        |«      | _        y)a?  
        Expand the GROUP BY clause required by the query.

        This will usually be the set of all non-aggregate fields in the
        return data. If the database backend supports grouping by the
        primary key, and the query would be equivalent, the optimization
        will be made automatically.
        N)r½  r$  r¿   rE   r   r¹   r
  rN   rÃ   r‰   rv   r    r  rÿ   r¢  r   r±  r  )	rw   rI  Úgroup_by_annotationsr½  rÇ   rH   r  r   Úgroup_by_colss	            r;   rS  zQuery.set_group_byè  s+  € ñ ˜T×/Ò/ð $&Ð ØˆMÜ" 4×#5Ñ#5°t·{±{ÓCò 7‘��tÜ˜d¤CÔ(Ø+/�M %Ò(à26Ð(¨Ò/ð	7ð
  LÐ"6ÐK¸$×:JÑ:JÐKˆDÔØ×'Ñ'Ð(<Ô=Ü × 4Ñ 4Ó 6Ó7ˆDŒKÜ!& }Ó!5ˆDÔÜ˜Ÿ™Ó$ˆØ!%×!7Ñ!7×!=Ñ!=Ó!?ò 	/ÑˆE�:Ø%/×%AÑ%AÓ%CÐC�MÐCØÙ Z×%BÒ%BØ—‘¤ E¨:Ó 6Õ7à—‘ Õ.ð	/ô ˜h›ˆ�rB   c                 óÎ   — t        | j                  t        «      ri }n| j                  }|D ]0  }|}|j                  t        «      D ]  }|j                  |i «      }Œ Œ2 || _        y)z³
        Set up the select_related data structure so that we only select
        certain related models (as opposed to all models, when
        self.select_related=True).
        N)rE   rà   Úboolr™  r   rƒ  )rw   ÚfieldsÚ
field_dictrÁ   Údr�  s         r;   Úadd_select_relatedzQuery.add_select_related		  sj   € ô �d×)Ñ)¬4Ô0Ø‰Jà×,Ñ,ˆJØò 	+ˆEØˆAØŸ™¤JÓ/ò +�Ø—L‘L  rÓ*‘ñ+ð	+ð )ˆÕrB   c                 óT  — |rÎi }|rt        |«      }nt        g «      }|j                  «       D ]…  \  }	}
| j                  |	«       t        |
«      }
g }|
j	                  d«      }|dk7  rE|dk(  s|
|dz
     dk7  r|j                  t        |«      «       |
j	                  d|dz   «      }|dk7  rŒE|
|f||	<   Œ‡ | j                  j                  |«       |s|r*| j                  j                  t        ||«      t        «       |r| xj                  t        |«      z  c_        |r|| _        yy)zm
        Add data to the various extra_* attributes for user-created additions
        to the query.
        z%srÜ  r   rT   ú%rf  N)rŠ   r    r  rÊ  Úfindr¢  rÂ   rº   rt  r¸   r  r*   r(   rv  rN   rx  )rw   r¿   Úselect_paramsr¸   ro   Útablesrw  Úselect_pairsÚ
param_iterr6   ÚentryÚentry_paramsrÃ  s                r;   Ú	add_extrazQuery.add_extra	  s  € ñ
 ð
 ˆLÙÜ! -Ó0‘
ä! "›X�
Ø%Ÿ|™|›~ò 	;‘��eØ× Ñ  Ô&Ü˜E›
�Ø!�Ø—j‘j Ó&�Ø˜R’iØ˜a’x 5¨¨q©¡>°SÒ#8Ø$×+Ñ+¬D°Ó,<Ô=ØŸ*™* T¨3°©7Ó3�Cð ˜R“ið ',¨\Ð%:�˜TÒ"ð	;ð �J‰J×Ñ˜lÔ+Ù‘FØ�J‰J�N‰Nœ: e¨VÓ4´cÔ:ÙØ×Ò¤ v£Ñ.ÕÙØ"*ˆDÕð rB   c                 ó&   — t        «       df| _        y)z0Remove any fields from the deferred loading set.TN)Ú	frozensetr˜  r’   s    r;   Úclear_deferred_loadingzQuery.clear_deferred_loading:	  s   € ä!*£¨dÐ 3ˆÕrB   c                 óþ   — | j                   \  }}|r|j                  |«      df| _         y|j                  |«      x}r
|df| _         y| j                  «        t	        |«      j                  |«      x}r
|df| _         yy)aj  
        Add the given list of model field names to the set of fields to
        exclude from loading from the database when automatic column selection
        is done. Add the new field names to any existing field names that
        are deferred (or removed from any existing field names that are marked
        as the only ones for immediate loading).
        TFN)r˜  rJ  Ú
differencerè  r=   )rw   rš  Úexistingr›  Únew_existingÚnew_onlys         r;   Úadd_deferred_loadingzQuery.add_deferred_loading>	  sŠ   € ð ×/Ñ/‰ˆ�%Ùà$,§N¡N°;Ó$?ÀÐ$EˆDÕ!ð  (×2Ñ2°;Ó?Ð?ˆ|Ð?Ø(4°eÐ(;�Õ%à×+Ñ+Ô-Ü" ;Ó/×:Ñ:¸8ÓDÐD�8ÐDØ,4°d¨N�DÕ)ð ErB   c                 ó"  — | j                   \  }}t        |«      }d|v rD|j                  d«       |j                  | j	                  «       j
                  j                  «       |r|j                  |«      df| _         yt        |«      df| _         y)a  
        Add the given list of model field names to the set of fields to
        retrieve when the SQL is executed ("immediate loading" fields). The
        field names replace any existing immediate loading field names. If
        there are field names already specified for deferred loading, remove
        those names from the new field_names before storing the new names
        for immediate loading. (That is, immediate loading overrides any
        existing immediate values, but respects existing deferrals.)
        r  FN)	r˜  r=   Úremover  r×   r  r6   rê  rç  )rw   rš  rë  r›  s       r;   Úadd_immediate_loadingzQuery.add_immediate_loadingW	  s‚   € ð ×/Ñ/‰ˆ�%Ü˜+Ó&ˆØ�;ÑØ×Ñ˜tÔ$Ø�O‰O˜DŸM™M›O×.Ñ.×3Ñ3Ô4áð %0×$:Ñ$:¸8Ó$DÀeÐ$KˆDÕ!ô %.¨kÓ$:¸EÐ$AˆDÕ!rB   c                 óz   — |€d| _         d| _        yt        t        j                  |«      «      | _         d| _        y)z@Set the mask of annotations that will be returned by the SELECT.N)rÛ   r‰   r•   rò  rÝ   ©rw   rs  s     r;   r  zQuery.set_annotation_masko	  s9   € àˆ=Ø*.ˆDÔ'ð )-ˆÕ%ô +/¬t¯}©}¸UÓ/CÓ*DˆDÔ'Ø(,ˆÕ%rB   c                 ó^   — | j                   �!| j                  g | j                   ¢|¢­«       y y r4   )rÛ   r  ró  s     r;   r
  zQuery.append_annotation_maskw	  s2   € Ø×&Ñ&Ð2Ø×$Ñ$Ð%K t×'BÑ'BÐ%KÀUÑ%KÕLð 3rB   c                 óT   — |€d| _         d| _        yt        |«      | _         d| _        y)zž
        Set the mask of extra select items that will be returned by SELECT.
        Don't remove them from the Query since they might be used later.
        N)rÞ   r=   rß   ró  s     r;   ru  zQuery.set_extra_mask{	  s1   € ð
 ˆ=Ø%)ˆDÔ"ð $(ˆÕ ô &)¨£ZˆDÔ"Ø#'ˆÕ rB   c                 ód  — d| _         | j                  «        | j                  «        d| _        |�r7|D ]  }| j	                  |«       Œ g }g }g }| j
                  s| j                  st        |«      }nÁd| _        |D ]µ  }|| j                  v r|j                  |«       Œ#|| j                  v r|j                  |«       ŒC|| j                  v rt        d|› d�«      ‚| j                  r9| j                  |j                  t        «      | j                   j"                  «       |j                  |«       Œ· | j%                  |«       | j'                  |«       t)        ||z   |z   «      }nB| j                   j"                  j*                  D �cg c]  }|j,                  ‘Œ }}t)        |«      }| j.                  du rZ| j1                  d„ | j                   j"                  j*                  D «       d«       | j3                  d¬«       | j                  «        nw| j.                  rkg }| j.                  D ]J  }	t5        |	t6        «      r'|	j8                  |vr| j                  |	j8                     }	|j                  |	«       ŒL t;        |«      | _        t;        |«      | _        | j1                  |d«       y c c}w )NFTzCannot select the 'z&' alias. Use annotate() to promote it.c              3   ó4   K  — | ]  }|j                   –— Œ y ­wr4   rF  r8   s     r;   r<   z#Query.set_values.<locals>.<genexpr>³	  s   è ø€ ÒE˜q�—•ÑEùrG  rH  )rà   rè  r¾  r  r  rº   r¹   r‰   r  ru   r¢  rv   r   r  r™  r   r±   rÖ   ru  r  rç  rR  r7   r  rQ  rS  rE   r   ÚrefsrN   r½  )
rw   rØ  rÁ   rš  Úextra_namesÚannotation_namesr:   Úselectedr  rH   s
             r;   Ú
set_valueszQuery.set_values†	  sg  € Ø#ˆÔØ×#Ñ#Ô%Ø× Ñ Ô"Ø!%ˆÔâØò (�Ø× Ñ  Õ'ð(àˆKØˆKØ!ÐØ—:’: d×&6Ò&6ô # 6›l‘à$)�Ô!Øò .�AØ˜D×-Ñ-Ñ-Ø#×*Ñ*¨1Õ-Ø˜d×4Ñ4Ñ4Ø(×/Ñ/°Õ2Ø˜d×.Ñ.Ñ.Ü(Ø1°!°ð 5*ð *óð ð  ×1Ò1Ø ×.Ñ.¨q¯w©w´zÓ/BÀDÇJÁJ×DTÑDTÔUØ#×*Ñ*¨1Õ-ð!.ð" ×Ñ Ô,Ø×$Ñ$Ð%5Ô6Ü  ¨{Ñ!:Ð=MÑ!MÓN‰Hà.2¯j©j×.>Ñ.>×.NÑ.NÖO¨˜1Ÿ9›9ÐOˆKÐOÜ  Ó-ˆHð �=‰=˜DÑ Ø�O‰OÙE D§J¡J×$4Ñ$4×$DÑ$DÔEÀuôð
 ×Ñ¨EÐÔ2Ø×$Ñ$Õ&Ø�]Š]ð ˆHØŸ™ò &�Ü˜d¤CÔ(¨T¯Y©Y¸hÑ-FØ×+Ñ+¨D¯I©IÑ6�DØ—‘ Õ%ð&ô " (›OˆDŒMä" ;Ó/ˆÔØ�‰˜ TÕ*ùò/ Ps   ÆJ-c                 ó  — | j                   �| j                   S | j                  si S | j                  �G| j                  D �ci c]   }|| j                  v r|| j                  |   “Œ" c}| _         | j                   S | j                  S c c}w )z¤
        Return the dictionary of aggregate columns that are not masked and
        should be used in the SELECT clause. Cache this result for performance.
        )rÝ   r¹   rÛ   )rw   rG  s     r;   rv   zQuery.annotation_selectÆ	  s–   € ð ×(Ñ(Ð4Ø×0Ñ0Ð0Ø×!Ò!ØˆIØ×(Ñ(Ð4ð ×4Ñ4ö-àØ˜×(Ñ(Ñ(ð �4×#Ñ# AÑ&Ñ&ò-ˆDÔ)ð
 ×0Ñ0Ð0à×#Ñ#Ð#ùò-s   Á%Bc                 ó&  — | j                   �| j                   S | j                  si S | j                  �N| j                  j                  «       D ��ci c]  \  }}|| j                  v sŒ||“Œ c}}| _         | j                   S | j                  S c c}}w r4   )rß   rº   rÞ   r    )rw   rG  r  s      r;   ru   zQuery.extra_selectÚ	  s‰   € à×#Ñ#Ð/Ø×+Ñ+Ð+Ø�zŠzØˆIØ×#Ñ#Ð/à!%§¡×!1Ñ!1Ó!3÷(Ù˜˜A°q¸D×<RÑ<RÒ7R��1‘ó(ˆDÔ$ð ×+Ñ+Ð+à—:‘:Ðùó(s   ÁBÁ'Bc                 ód  — g }|D ]  \  }}|j                  |«       Œ d}| j                  D �cg c]"  }|| j                  v s|| j                  k(  sŒ!|‘Œ$ }}t	        |«      D ]Q  \  }}	|	j
                  r n@| j                  ||dz         j                  t        k(  rd}||   }
| j                  |
«       ŒS 	j                  j                  }}g }|D ]7  \  }}	|t        |	«      z
  dk  r n!|j                  |«       |t        |	«      z  }Œ9 |j                  |j                  d   j                  «       t        j                   |«      }| j                  ||dz         }|j                  t        k7  r|j"                  ss|j$                  D �cg c]  }|d   ‘Œ	 }}||dz      }| j                  ||   «       |j'                  d||dz      «      }|rB| j(                  j+                  |t,        «       n!|j$                  D �cg c]  }|d   ‘Œ	 }}||   }| j                  D ]L  }| j.                  |   dkD  sŒ| j1                  | j                  |   j2                  |«      | j                  |<    n | j5                  |D �cg c]  }|j7                  |«      ‘Œ c}«       ||fS c c}w c c}w c c}w c c}w )aî  
        Trim joins from the start of the join path. The candidates for trim
        are the PathInfos in names_with_path structure that are m2m joins.

        Also set the select column so the start matches the join.

        This method is meant to be used for generating the subquery joins &
        cols in split_exclude().

        Return a lookup usable for doing outerq.filter(lookup=self) and a
        boolean indicating if the joins in the prefix contain a LEFT OUTER join.
        _FrT   Tr   N)r±  r³   r<  rÈ   r¿  rq  rh  r!   rp  rô  rÁ   r¾   r¢  r”  r6   r   r`  r’  r–  Úget_extra_restrictionr¸   r  r(   r²   r×  r£  rs  rï   )rw   r>  Ú	all_pathsr-  Úpathsr¨  r‘  Úlookup_tablesÚtrimmed_pathsrj   rÇ   rô  Úpaths_in_prefixr§  r6   Ú
first_joinrš  Úselect_fieldsÚselect_aliasÚextra_restrictionrø  r:   s                         r;   r¦  zQuery.trim_startè	  sÇ  € ð ˆ	Ø'ò 	$‰HˆAˆuØ×Ñ˜UÕ#ð	$àˆð
 —~‘~ö
Ø¨¨d×.@Ñ.@Ñ)@ÀAÈÏÉÓDXŠAð
ˆð 
ô $-¨YÓ#7ò 	$ÑˆM˜4Ø�xŠxÙØ�~‰~˜m¨M¸AÑ,=Ñ>Ñ?×IÑIÌVÒSØ"&�Ø! -Ñ0ˆEØ×Ñ˜UÕ#ð	$ð —_‘_×*Ñ*ˆ
à'ˆØˆØ)ò 	)‰JˆD�$Ø¤ T£Ñ*¨QÒ.ÙØ×!Ñ! $Ô'Øœs 4›yÑ(‰Oð		)ð
 	×Ñ˜j×?Ñ?ÀÑB×GÑGÔHÜ#Ÿ™¨Ó8ˆð —^‘^ M°-À!Ñ2CÑ$DÑEˆ
Ø×Ñ¤6Ò)°*×2NÒ2NØ+5×+DÑ+DÖE a˜Q˜q›TÐEˆMÐEØ(¨¸Ñ):Ñ;ˆLØ×Ñ˜]¨=Ñ9Ô:Ø *× @Ñ @Ø�m M°AÑ$5Ñ6ó!Ðñ !Ø—
‘
—‘Ð0´#Õ6ð
 ,6×+DÑ+DÖE a˜Q˜q›TÐEˆMÐEØ(¨Ñ7ˆLð —^‘^ò 	ˆEØ×"Ñ" 5Ñ)¨AÓ-Ø(,×(=Ñ(=Ø—N‘N 5Ñ)×4Ñ4Øó)�—‘˜uÑ%ñ ð	ð 	�‰¸-ÖH°Q˜Ÿ™ <Õ0ÒHÔIØ˜Ð.Ð.ùòo
ùò< Fùò Fùò Is   ®"JÁJÆJ#Ç>J(É;J-c                 ó|   — |j                   xs/ |j                  xr! t        t           j                  j
                  S )a  
        Check if the given field should be treated as nullable.

        Some backends treat '' as null and Django treats such fields as
        nullable for those backends. In such situations field.null can be
        False even if we should treat the field as nullable.
        )ÚnullÚempty_strings_allowedr   r   r‡   r&  )rw   rÁ   s     r;   r@  zQuery.is_nullable5
  s9   € ð �z‰zò 
Ø×'Ñ'ò YÜÔ,Ñ-×6Ñ6×XÑXð	
rB   )T)NNTr4   )FN)rT   )F)FFNTTTFT)FFTTTFT)TF)NT)FT)TNF)NN)Šr‘   r¥   r¦   r§   r¡  r  rç  rÙ   rÓ   r$   r×  r&   rŠ  r  rÌ  Ústandard_orderingrç   r  r¿   r  rw  rs   rt   r  rk  r  Úselect_for_update_nowaitÚselect_for_update_skip_lockedÚselect_for_update_ofÚselect_for_no_key_updaterà   r  Ú	max_depthr½  rÛ   rÝ   r  Úcombinator_allrÜ   rÞ   rß   rv  rx  r˜  r_  rx   r¨   rÄ   r-   rÈ   r˜   rÊ   rÑ   rÌ   r×   rz   r   rì   rð   r=  rA  rC  rM  rY  rc  r€  rˆ  r–  rž  r¥  r¨  rp  r´  r·  r¼  rê   rl  r  rÚ  r`  rë  r  rV  rL   rü  r  rÍ   r  r  r  r  r  r+  r#  rN  rS  rP  rX  rZ  r;  rg  r  rå  r?  Úclassmethodr  r   r¤  r=  r¬  r¯  rU  r   r  r·  r¹  rT  r¾  rÀ  rs  rÄ  rQ  rÐ  r  rS  rÛ  rå  rè  rî  rñ  r  r
  ru  rü  rv   ru   r¦  r@  r›   rB   r;   r0   r0   Û   s…  „ Ùà€LØ!ÐÙ˜l˜^Ó,€Là€Hà ÐØ€Jà€LØÐØÐàÐØ€Hð €Fð €HØ€HØ€HØ€IØ€HØ€OØÐØ$ÐØ$)Ð!ØÐØ$ÐØ€NØÐà€Ið €Mð "ÐØ#Ðð €JØ€NØÐð ÐØÐà€LØ€Nñ "› TÐ*Ðà€Ló&ð8 ñLó ðLð ñó ðò	ò<òó
ò$ò+óZòò
,ò
r@òhNòóò,&ó

3òrHóh*óXò"6ó,ò6(ó-ò#òJ1ò&2ò-
ó^5
ònòKó4òl#òBó-òò:
óòóó*0ò.
òAò.,ò,ò\ð2 ØØØØØØØób?òH0ò*ò&Dò!ð ØØØØØØó'+òR!NóFr<ðr ØóqTòf)ð@ òó ðð" ñAó ðAó0òdC'òJò
Lóò.0ð ñ@ó ð@òTò"ò%ò ò&ò"òó,ò\"*óH*ó (òB)ò +òB4ò;ò2Bò0-òMò	(ò>+ð@ ñ$ó ð$ð& ñó ðòK/óZ
rB   c                 óF   — t         |   }| d   dk(  r
| dd |d   fS | |d   fS )a  
    Return the field name and direction for an order specification. For
    example, '-foo' is returned as ('foo', 'DESC').

    The 'default' param is used to indicate which way no prefix (or a '+'
    prefix) should sort. The '-' prefix always sorts the opposite way.
    r   rÉ  rT   N)r"   )rÁ   ÚdefaultÚdirns      r;   Úget_order_dirr  H
  s<   € ô �WÑ€DØˆQ�x�3‚Ø�Q�Rˆy˜$˜q™'Ð!Ð!Ø�$�q‘'ˆ>ÐrB   c                   ó(   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zy)rm  z]
    A class to abstract away join promotion problems for complex filter
    conditions.
    c                 óÈ   — || _         || _        | j                  r!|t        k(  rt        | _        nt        | _        n| j                   | _        || _        t        «       | _        y r4   )rc   rd   r(   r)   Úeffective_connectorÚnum_childrenr   Úvotes)rw   rc   r  rd   s       r;   rx   zJoinPromoter.__init__\
  sN   € Ø"ˆŒØˆŒØ�<Š<ØœCÒÜ+-�Õ(ä+.�Õ(à'+§~¡~ˆDÔ$Ø(ˆÔô “Yˆ�
rB   c                 ó‚   — | j                   j                  › d| j                  ›d| j                  ›d| j                  ›d�S )Nz(connector=z, num_children=z
, negated=ú))r�   r¦   rc   r  rd   r’   s    r;   r“   zJoinPromoter.__repr__k
  sG   € à�~‰~×*Ñ*Ð+¨;°t·~±~Ð6Hð IØ ×-Ñ-Ð0°
¸4¿<¹<Ð:JÈ!ðMð	
rB   c                 ó:   — | j                   j                  |«       y)z`
        Add single vote per item to self.votes. Parameter can be any
        iterable.
        N)r  rt  )rw   r  s     r;   rn  zJoinPromoter.add_votesq
  s   € ð
 	�
‰
×Ñ˜%Õ rB   c                 ó¬  — t        «       }t        «       }| j                  j                  «       D ]€  \  }}| j                  t        k(  r || j
                  k  r|j                  |«       | j                  t        k(  s$| j                  t        k(  sŒ`|| j
                  k(  sŒp|j                  |«       Œ‚ |j                  |«       |j                  |«       |S )a  
        Change join types so that the generated query is as efficient as
        possible, but still correct. So, change as many joins as possible
        to INNER, but don't make OUTER joins INNER if that could remove
        results from the query.
        )
r=   r  r    r  r)   r  r  r(   r´  r·  )rw   rä   Ú
to_promoteÚ	to_demoterø  r  s         r;   rq  zJoinPromoter.update_join_typesx
  s¹   € ô “Uˆ
Ü“Eˆ	ð !ŸJ™J×,Ñ,Ó.ò 	%‰LˆE�5ð ×'Ñ'¬2Ò-°%¸$×:KÑ:KÒ2KØ—‘˜uÔ%ð ×'Ñ'¬3Ò.Ø×(Ñ(¬BÓ.°5¸D×<MÑ<MÓ3Mà—‘˜eÕ$ð5	%ðT 	×Ñ˜JÔ'Ø×Ñ˜9Ô%ØÐrB   N)r‘   r¥   r¦   r§   rx   r“   rn  rq  r›   rB   r;   rm  rm  V
  s   „ ñò
ò
ò!ó7rB   rm  )ÚASC)Sr§   rZ   r.  r†  rÑ  Úcollectionsr   r   Úcollections.abcr   r   Ú	itertoolsr   r   r	   Ústringr
   Údjango.core.exceptionsr   r   Ú	django.dbr   r   r   Údjango.db.models.aggregatesr   Údjango.db.models.constantsr   Údjango.db.models.expressionsr   r   r   r   r   r   r   r   Údjango.db.models.fieldsr   Ú'django.db.models.fields.related_lookupsr   Údjango.db.models.lookupsr   Údjango.db.models.query_utilsr   r   r   Údjango.db.models.sql.constantsr    r!   r"   r#   Ú#django.db.models.sql.datastructuresr$   r%   r&   r'   Údjango.db.models.sql.wherer(   r)   r*   r+   r,   Údjango.utils.functionalr-   Údjango.utils.regex_helperr.   Údjango.utils.treer/   Ú__all__rí  r]  rA   rJ   rG   rY   rV   rf   r1   r©   r0   r  rm  r›   rB   r;   ú<module>r9     s  ðñó Û Û Û 
ß +ß -ß +Ñ +Ý "ç @ß FÑ FÝ -Ý 1÷	÷ 	ó 	õ *Ý BÝ +÷ñ ÷
 LÓ Kß QÓ Qß RÕ RÝ 3Ý 6Ý "à�JÐ
€ñ +Ð+FÓGÐ ñ +¨9Ó5Ð òò6ò
8ò!òHñ ØØMó€÷F.ñ F.ñR ˜Ð(=Ó>€ôj%
ˆNô j%
óZK÷Yò YrB   