+
    TjM                     Z   R t ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIH	t	 ^ RI
HtHtHtHtHt ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ]P0                  ! R
4      t]! RR4      tR t ! R R]P8                  4      t ! R R4      t ! R R4      t ! R R4      t R t!R t"R t# ! R R4      t$R# )z
Various data structures used in query construction.

Factored out from django.db.models.query to avoid making the main module very
large and/or so that they can be used by other modules without getting into
circular import difficulties.
N)
namedtuple)nullcontext)
FieldError)DEFAULT_DB_ALIASDatabaseErrorconnectionsmodelstransaction)
LOOKUP_SEP)tree)cached_property)make_hashabledjango.db.modelsPathInfozGfrom_opts to_opts target_fields join_field m2m direct filtered_relationc              #   n   "   V x  V P                  4        F  p\        V4       R j  xL
  K  	  R #  L
5iN)__subclasses__
subclassesclssubclasss   & Q/var/www/idalgo/venv/lib/python3.14/site-packages/django/db/models/query_utils.pyr   r   !   s.     
I&&(h''' )'s   &535c                      a a ] tR t^'t oRtRtRtRt]tRt	R]]]3t
RRRR	/V 3R
 lltR tR tR tR tR tRR ltR tR t]3R ltR t]R 4       tR tR t]R 4       tRtVtV ;t# )QzY
Encapsulate filters as objects that can then be combined logically (using
`&` and `|`).
ANDORXORTN
_connector_negatedFc                  < WP                   9  d9   R P                  R V P                   R,           4       4      p\        RV R24      h\        SV `  . VO\        VP                  4       4      OVVR7       R# )z, c              3   (   "   T F  q: x  K
  	  R # 5ir    ).0conns   & r   	<genexpr>Q.__init__.<locals>.<genexpr>7   s     'T@S(@Ss   :   NNz_connector must be one of z
, or None.)children	connectornegatedN)
connectorsjoin
ValueErrorsuper__init__sorteditems)selfr   r   argskwargsconnector_reprs	__class__s   &$$*, r   r.   
Q.__init__5   sq    __,"ii'TPR@S'TTO9/9J*UVV5t5fV\\^45  	 	
    c                2   \        VR R4      RJ d   \        V4      hV '       g   VP                  4       # V'       g'   \        V\        4      '       d   V P                  4       # V P                  VR7      pVP                  W4       VP                  W4       V# )conditionalF)r(   )getattr	TypeErrorcopy
isinstancer   createadd)r1   otherr#   objs   &&& r   _combine
Q._combine?   su    5-/58E""::<E1--99;kkDk)
r7   c                8    V P                  WP                  4      # r   )rB   r   r1   r@   s   &&r   __or__Q.__or__L   s    }}UGG,,r7   c                8    V P                  WP                  4      # r   )rB   r   rE   s   &&r   __and__	Q.__and__O       }}UHH--r7   c                8    V P                  WP                  4      # r   )rB   r   rE   s   &&r   __xor__	Q.__xor__R   rK   r7   c                F    V P                  4       pVP                  4        V# r   )r<   negate)r1   rA   s   & r   
__invert__Q.__invert__U   s    iik


r7   c           	     Z    VP                  V VVR R VR7      w  rgVP                  V4       V# )F)allow_joins
split_subqcheck_filterable	summarize)_add_qpromote_joins)r1   queryrT   reuserW   for_saveclausejoinss   &&&&&&  r   resolve_expressionQ.resolve_expressionZ   s@    
 #" % 
 	E"r7   c                   V'       g   V # V P                  V P                  V P                  R 7      pV P                   EF  pTp\	        V\
        4      '       d   Vw  rV\        V9   d   VP                  \        ^4      w  rxMTpRp\        P                  ! V4      p	V	P                  V4      ;p
V	Jdw   Vf   RpV
P                  V4      ;pf2   V
P                  V4      ;p e   V! V
4      p
RpV
P                  V4      pVf   VR8X  d   V
P                  R4      pRpVe	   V! W4      pMVP                  V4      pVP                  P                  V4       EK  	  V# ))r(   r)   NexactisnullT)r>   r(   r)   r'   r=   tupler
   rsplitr   Freplace_expressions
get_lookupget_transformappend)r1   replacementsclonechildchild_replacementlhsrhspathlookupfieldfield_replacementlookup_classtransform_classs   &&           r   rg   Q.replace_expressionsj   s]   KdnndllK]]E %%'' $#&::j!#<LD&D!F).)B)B<)PP% ~!((9(D(DV(LLU/@/N/Nv/VVO!%& 1@@Q0R-%,F+<+G+G+OL{v'8'8'C'CH'M"#/,89J,P)$)$=$=l$K!NN!!"34A #B r7   c              #     "   V x  V P                    FR  p\        V\        4      '       d
   V^,          p\        VR4      '       d   VP	                  4        Rj  xL
  KN  Vx  KT  	  R#  L5i)zO
Recursively yield this Q object and all subexpressions, in depth-first
order.
flattenN)r'   r=   rd   hasattrry   )r1   rm   s   & r   ry   	Q.flatten   sV     
 
]]E%''aui(( ==?** #
 +s   AA-A+A-c           
     *   ^ RI HpHp ^ RIHp ^ RIHp ^ RIHp V! R4      pVP                  4        F2  w  r\        V
R4      '       g	   V! V
4      p
VP                  WRR7       K4  	  VP                  V! ^4      R	4       \        V,          pVP                  P                  '       d*   VP                  \!        V! V R
V! 4       R7      4      4       MVP                  V 4       VP#                  VR7      pVP$                  '       d   \&        P(                  ! VR7      M	\+        4       p V;_uu_ 4        VP-                  V4      RJuuRRR4       #   + '       g   i     R# ; i  \.         d"   p\0        P3                  RY4        Rp?R
# Rp?ii ; i)zd
Do a database query to check if the expressions of the Q instance
matches against the expressions.
)BooleanFieldValue)Coalesce)Query)SINGLENr_   F)select_checkT)output_field)usingz.Got a database error calling check() on %r: %s)django.db.modelsr}   r~   django.db.models.functionsr   django.db.models.sqlr   django.db.models.sql.constantsr   r0   rz   add_annotationr   featuressupports_comparing_boolean_expradd_qr   get_compilerin_atomic_blockr	   atomicr   execute_sqlr   loggerwarning)r1   againstr   r}   r~   r   r   r   rZ   namevalue
connectioncompilercontext_manageres   &&&            r   checkQ.check   s4    	97.9d"==?KD5"677e  U ; + 	U1Xx0 '
>>>KK(4LNKLMKK%%E%2 ))) U+ 	
	 ++F34? ! 	NNKTU	s6   *
E& 4E
E& E#	E& #E& &F1FFc                n   V P                   P                  : R V P                   P                  : 2pVP                  R4      '       d   VP	                  RR4      p\        V P                  4      p/ pV P                  V P                  8w  d   V P                  VR&   V P                  '       d   RVR&   WV3# ).zdjango.db.models.query_utilsr   r   Tr   )
r5   
__module____name__
startswithreplacerd   r'   r(   defaultr)   )r1   rq   r2   r3   s   &   r   deconstructQ.deconstruct   s    ..33T^^5L5LM??9::<< >@RSDT]]#>>T\\)#'>>F< <<<!%F:6!!r7   c                
   V P                  4       w  rpV.VP                  4       OpV FM  p\        V\        4      '       d$   Vw  rg\	        V4      pVP                  Wg34       K<  VP                  V4       KO  	  \        V4      # r   )r   r0   r=   rd   r   rj   )r1   rq   r2   r3   identityrm   argr   s   &       r   r   
Q.identity   sv    !--/F*6<<>*E%''"
%e,-&  Xr7   c                l    \        V\        4      '       g   \        # VP                  V P                  8H  # r   )r=   r   NotImplementedr   rE   s   &&r   __eq__Q.__eq__   s(    %##!!~~..r7   c                ,    \        V P                  4      # r   )hashr   )r1   s   &r   __hash__
Q.__hash__   s    DMM""r7   c                    ^ RI Hp VP                  V 4       Uu0 uF  q"P                  \        ^4      ^ ,          kK!  	  up# u upi )zv
Retrieve all base fields referenced directly or through F expressions
excluding any fields referenced through joins.
)rZ   )r   rZ   get_children_from_qsplitr
   )r1   rZ   rm   s   &  r   referenced_base_fieldsQ.referenced_base_fields   sH     	/ 8=7P7PQU7V
7VeKK
A&q))7V
 	
 
s   %Ar!   )NTNFF)r   r   __qualname____firstlineno____doc__r   r   r   r   r9   r*   r.   rB   rF   rI   rM   rQ   r_   rg   ry   r   r   r   r   r   r   r   r   __static_attributes____classdictcell____classcell__)r5   __classdict__s   @@r   r   r   '   s      C	B
CGKR%J
 
 
-..
 %N $4 "H
" 
 
/
# 

 

 

r7   r   c                   :   a  ] tR t^t o RtR tRR ltR tRtV t	R# )DeferredAttributezx
A wrapper for a deferred-loading field. When the value is read from this
object the first time, the query is executed.
c                    Wn         R # r   rs   )r1   rs   s   &&r   r.   DeferredAttribute.__init__   s    
r7   Nc                "   Vf   V # VP                   pV P                  P                  pWC9  d[   V P                  V4      pVfB   VP	                  4       '       g   \        RV: R24      hVP                  V.R7       W4,          # WSV&   W4,          # )z`
Retrieve and caches the value from the datastore on the first lookup.
Return the cached value.
zCannot retrieve deferred field z from an unsaved model.)fields)__dict__rs   attname_check_parent_chain
_is_pk_setAttributeErrorrefresh_from_db)r1   instancer   data
field_namevals   &&&   r   __get__DeferredAttribute.__get__   s    
 K  ZZ''
! **84C{**,,(9* H1 1  (((=  $'Z r7   c                    VP                   pVP                  V P                  P                  4      pV P                  P                  '       d'   V P                  V8w  d   \        WP                  4      # R# )z
Check if the field value can be fetched from a parent field already
loaded in the instance. This can be done if the to-be fetched
field is a primary key field.
N)_metaget_ancestor_linkrs   modelprimary_keyr:   r   )r1   r   opts
link_fields   &&  r   r   %DeferredAttribute._check_parent_chain  sV     ~~++DJJ,<,<=
::!!!djjJ&>8%7%788r7   r   r   )
r   r   r   r   r   r.   r   r   r   r   r   s   @r   r   r      s     
 0
 
r7   r   c                   0   a  ] tR tRt o RtR tR tRtV tR# )class_or_instance_methodi!  z
Hook used in RegisterLookupMixin to return partial functions depending on
the caller type (instance or class of models.Field).
c                    Wn         W n        R # r   class_methodinstance_method)r1   r   r   s   &&&r   r.   !class_or_instance_method.__init__'  s    (.r7   c                    Vf"   \         P                  ! V P                  V4      # \         P                  ! V P                  V4      # r   )	functoolspartialr   r   )r1   r   owners   &&&r   r    class_or_instance_method.__get__+  s:    $$T%6%6>>  !5!5x@@r7   r   N)	r   r   r   r   r   r.   r   r   r   r   s   @r   r   r   !  s     
/A Ar7   r   c                   
  a  ] tR tRt o R t]P                  R 4       tR t]	! ]]4      t
]! ]4      tR tR t]R 4       t]R 4       tRR
 ltRR lt]	! ]]4      t]! ]4      tRR ltRR lt]	! ]]4      t]! ]4      tRtV tR	# )RegisterLookupMixini1  c                B    V P                  4       P                  VR 4      # r   )get_lookupsget)r1   lookup_names   &&r   _get_lookupRegisterLookupMixin._get_lookup2  s    !%%k488r7   c                    \         P                  ! V 4       Uu. uF  qP                  P                  R / 4      NK   	  ppV P	                  V4      # u upi )class_lookups)inspectgetmror   r   merge_dicts)r   parentr   s   &  r   get_class_lookups%RegisterLookupMixin.get_class_lookups5  sR     DK>>RUCV
CVOO4CV 	 
 }--
s   $Ac                \    V P                  4       p\        V R R4      ;p'       d   / VCVC# V# )instance_lookupsN)r   r:   )r1   r   r   s   &  r   get_instance_lookups(RegisterLookupMixin.get_instance_lookups<  s=    ..0&t-?FFF8m8'788r7   c                    ^ RI Hp V P                  V4      pVf.   \        V R4      '       d   V P                  P                  V4      # Ve   \        W24      '       g   R# V# )    )LookupNr   )django.db.models.lookupsr   r   rz   r   rh   
issubclass)r1   r   r   founds   &&  r   rh   RegisterLookupMixin.get_lookupE  sU    3  -=WT>::$$//<<Z%>%>r7   c                    ^ RI Hp V P                  V4      pVf.   \        V R4      '       d   V P                  P                  V4      # Ve   \        W24      '       g   R# V# )r   )	TransformNr   )r   r  r   rz   r   ri   r   )r1   r   r  r   s   &&  r   ri   !RegisterLookupMixin.get_transformO  sU    6  -=WT>::$$22;??Z%A%Ar7   c                P    / p\        V 4       F  pVP                  V4       K  	  V# )z
Merge dicts in reverse to preference the order of the original list.
e.g., merge_dicts([a, b]) will preference the keys in 'a' over those in
'b'.
)reversedupdate)dictsmergedds   &  r   r   RegisterLookupMixin.merge_dictsY  s(     %AMM! !r7   c                ^    \        V 4       F  pVP                  P                  4        K  	  R # r   )r   r   cache_clearr   s   & r   _clear_cached_class_lookups/RegisterLookupMixin._clear_cached_class_lookupse  s"    "3H&&224 (r7   Nc                    Vf   VP                   pRV P                  9  d   / V n        WP                  V&   V P                  4        V# )Nr   )r   r   r   r  r   rr   r   s   &&&r   register_class_lookup)RegisterLookupMixin.register_class_lookupj  sF     ,,K#,,. "C)/+&'')r7   c                r    Vf   VP                   pRV P                  9  d   / V n        WP                  V&   V# )Nr   )r   r   r   r1   rr   r   s   &&&r   register_instance_lookup,RegisterLookupMixin.register_instance_lookups  s:     ,,KT]]2$&D!-3k*r7   c                `    Vf   VP                   pV P                  V V P                  4        R# )zV
Remove given lookup from cls lookups. For use in tests only as it's
not thread-safe.
N)r   r   r  r  s   &&&r   _unregister_class_lookup,RegisterLookupMixin._unregister_class_lookup  s/    
  ,,Kk*'')r7   c                @    Vf   VP                   pV P                  V R# )z[
Remove given lookup from instance lookups. For use in tests only as
it's not thread-safe.
N)r   r   r  s   &&&r   _unregister_instance_lookup/RegisterLookupMixin._unregister_instance_lookup  s#    
  ,,K!!+.r7   )r   r   )r   r   r   r   r   r   cacher   r   r   r   classmethodrh   ri   staticmethodr   r  r  r  register_lookupr  r  _unregister_lookupr   r   r   s   @r   r   r   1  s     9 __. . ++<>RSK#$56 	 	 5 5 /7O ((=>*/ 2 "=  ++CDr7   r   c                T   V P                   '       g   R# \        V P                   RR4      '       d   R# V'       g   V P                  '       * # V P                  V9  d   R# V'       dA   W9  d;   \	        RV P
                  P                  P                   RV P                   R24      hR# )a  
Return whether `field` should be used to descend deeper for
`select_related()` purposes.

Arguments:
 * `field` - the field to be checked. Can be either a `Field` or
   `ForeignObjectRel` instance.
 * `restricted` - a boolean field, indicating if the field list has been
   manually restricted using a select_related() clause.
 * `requested` - the select_related() dictionary.
 * `select_mask` - the dictionary of selected fields.
Fparent_linkzField r   zM cannot be both deferred and traversed using select_related at the same time.T)remote_fieldr:   nullr   r   r   r   object_name)rs   
restricted	requestedselect_masks   &&&&r   select_related_descendr*    s      u!!=%88 ::~ zz" u/U[[&&2231UZZL AL L
 	
 r7   c                    \        ^\        V 4      ^,           4       F;  p\        P                  ! V ^ V 4      pVP	                  V4      '       g   K5  W0VR 3u # 	  R# )z
Check if the lookup_parts contains references to the given annotations set.
Because the LOOKUP_SEP is contained in the default annotation names, check
each prefix of the lookup_parts for a match.
N)Nr!   )rangelenr
   r+   r   )lookup_partsannotationsnlevel_n_lookups   &&  r   refs_expressionr2    sZ     1c,'!+,#a):;??>**!#333 - Or7   c                   a  V 3R lpV! V4      ;'       g2    \        VRR4      ;'       d    V! VP                  P                  4      # )z
Check that self.model is compatible with target_opts. Compatibility
is OK if:
  1) model and opts match (where proxy inheritance is removed)
  2) model is parent of opts' model or the other way around
c                    < SP                   P                  V P                  8H  ;'       g;    V P                  SP                   P                  9   ;'       g    SV P                  9   # r   )r   concrete_modelall_parents)r   r   s   &r   r   -check_rel_lookup_compatibility.<locals>.check  sZ    KK&&$*=*== ) )""ekk&=&==) )(((	
r7   r   F)r:   r   r   )r   target_optsrs   r   s   f&& r   check_rel_lookup_compatibilityr9    sD    
    }e,IIu{{7H7H1Ir7   c                   Z   a  ] tR tRt o RtR]! 4       /R ltR tR tR t	R t
R	 tR
tV tR# )FilteredRelationi  z7Specify custom filtering in the ON clause of SQL joins.	conditionc                   V'       g   \        R 4      hWn        RV n        \        V\        4      '       g   \        R4      hW n        RV n        R# )zrelation_name cannot be empty.Nz*condition argument must be a Q() instance.)r,   relation_namealiasr=   r   r<  resolved_condition)r1   r>  r<  s   &&$r   r.   FilteredRelation.__init__  sF    =>>*
)Q''IJJ #"&r7   c                    \        WP                  4      '       g   \        # V P                  VP                  8H  ;'       d;    V P                  VP                  8H  ;'       d    V P
                  VP
                  8H  # r   )r=   r5   r   r>  r?  r<  rE   s   &&r   r   FilteredRelation.__eq__  sd    %00!!%"5"55 2 2

ekk)2 2%//1	
r7   c                    \        V P                  V P                  R 7      pV P                  Vn        V P                  ;pe   VP                  4       Vn        V# ))r<  )r;  r>  r<  r?  r@  rl   )r1   rl   r@  s   &  r   rl   FilteredRelation.clone  sK     !3!3t~~Njj"&"9"99F'9'?'?'AE$r7   c                z    V P                  4       pVP                  ;p'       d   VP                  V4      Vn        V# r   )rl   r@  relabeled_clone)r1   
change_maprl   r@  s   &&  r   rG   FilteredRelation.relabeled_clone	  s7    

!&!9!999'9'I'I*'UE$r7   c                ~    V P                  4       pVP                  V P                  VR RRR7      ^ ,          Vn        V# )TF)	can_reuserT   rU   update_join_types)rl   build_filterr<  r@  )r1   rZ   r[   r2   r3   rl   s   &&&*, r   r_   #FilteredRelation.resolve_expression  sI    

#(#5#5NN# $6 $
 $  r7   c                8    VP                  V P                  4      # r   )compiler@  )r1   r   r   s   &&&r   as_sqlFilteredRelation.as_sql  s     7 788r7   )r?  r<  r>  r@  N)r   r   r   r   r   r   r.   r   rl   rG  r_   rQ  r   r   r   s   @r   r;  r;    s4     A'13 '
	9 9r7   r;  )%r   r   r   loggingcollectionsr   
contextlibr   django.core.exceptionsr   	django.dbr   r   r   r   r	   django.db.models.constantsr
   django.utilsr   django.utils.functionalr   django.utils.hashabler   	getLoggerr   r   r   Noder   r   r   r   r*  r2  r9  r;  r!   r7   r   <module>r^     s       " " - W W 1  3 /			-	.
 M(I
		 I
X+ +\A A eE eEP#L
:29 29r7   