https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/django/db/models/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/db/models/__pycache__/query_utils.cpython-310.pyc
o

3�a�0�@s�dZddlZddlZddlZddlZddlmZddlmZm	Z	ddl
mZddlm
Z
ddlmZedd	�ZGd
d�de�ZGdd
�d
eed�Zdd�ZGdd�de
j�ZGdd�d�ZGdd�d�Zd dd�Zdd�Zdd�ZGdd�d�ZdS)!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��FieldDoesNotExist�
FieldError)�
LOOKUP_SEP)�tree)�RemovedInDjango40Warning�PathInfozGfrom_opts to_opts target_fields join_field m2m direct filtered_relationcs<eZdZedd��Zdd�Z�fdd�Z�fdd�Z�ZS)	�InvalidQueryTypecCsttfS�Nr��self�r�>/usr/lib/python3/dist-packages/django/db/models/query_utils.py�_subclassesszInvalidQueryType._subclassescCstjdtdd�dS)Nz\The InvalidQuery exception class is deprecated. Use FieldDoesNotExist or FieldError instead.�)�category�
stacklevel)�warnings�warnrrrrr�__warns

�zInvalidQueryType.__warnc� |��t||j�pt��|�Sr)�_InvalidQueryType__warn�
isinstancer�super�__instancecheck__)r
�instance��	__class__rrr&�z"InvalidQueryType.__instancecheck__crr)r�
issubclassrr�__subclasscheck__)r
�subclassrrrr!*rz"InvalidQueryType.__subclasscheck__)	�__name__�
__module__�__qualname__�propertyrrrr!�
__classcell__rrrrr
s
r
c@seZdZdS)�InvalidQueryN)r#r$r%rrrrr(/sr()�	metaclassccs(�|V|��D]	}t|�EdHqdSr)�__subclasses__�
subclasses��clsr"rrrr+3s
��r+csjeZdZdZdZdZeZdZddd��fdd	�
Zd
d�Z	dd
�Z
dd�Zdd�Zddd�Z
dd�Z�ZS)�Qze
    Encapsulate filters as objects that can then be combined logically (using
    `&` and `|`).
    �AND�ORTNF)�
_connector�_negatedcs&t�jg|�t|����||d�dS)N)�children�	connector�negated)r�__init__�sorted�items)r
r1r2�args�kwargsrrrr6Ds&z
Q.__init__cCs�t|t�st|dd�dust|��|s!t|d�r|��St�|�St|t�r8|s8|��\}}}t|�|i|��St|��}||_|�	||�|�	||�|S)N�conditionalFT�copy)
rr.�getattr�	TypeError�hasattrr<�deconstruct�typer4�add)r
�other�conn�_r9r:�objrrr�_combineGs
z
Q._combinecC�|�||j�Sr)rGr0�r
rCrrr�__or__W�zQ.__or__cCrHr)rGr/rIrrr�__and__ZrKz	Q.__and__cCs$t|��}|�||j�|��|Sr)rArBr/�negate)r
rFrrr�
__invert__]s
zQ.__invert__cCs&|j|||ddd�\}}|�|�|S)NF)�allow_joins�
split_subq�check_filterable)�_add_q�
promote_joins)r
�queryrO�reuse�	summarize�for_save�clause�joinsrrr�resolve_expressioncs
�
zQ.resolve_expressioncCsfd|jj|jjf}|�d�r|�dd�}t|j�}i}|j|jkr'|j|d<|j	r.d|d<|||fS)Nz%s.%szdjango.db.models.query_utilszdjango.db.modelsr1Tr2)
rr$r#�
startswith�replace�tupler3r4�defaultr5)r
�pathr9r:rrrr@ms



z
Q.deconstruct)NTNFF)r#r$r%�__doc__r/r0r^r;r6rGrJrLrNrZr@r'rrrrr.9s

r.c@s*eZdZdZdd�Zd	dd�Zdd�ZdS)
�DeferredAttributez�
    A wrapper for a deferred-loading field. When the value is read from this
    object the first time, the query is executed.
    cCs
||_dSr)�field)r
rbrrrr6s
zDeferredAttribute.__init__NcCsZ|dur|S|j}|jj}||vr)|�|�}|dur%|j|gd�||S|||<||S)zx
        Retrieve and caches the value from the datastore on the first lookup.
        Return the cached value.
        N)�fields)�__dict__rb�attname�_check_parent_chain�refresh_from_db)r
rr-�data�
field_name�valrrr�__get__�s
�zDeferredAttribute.__get__cCs6|j}|�|jj�}|jjr|j|krt||j�SdS)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_linkrb�model�primary_keyr=re)r
r�opts�
link_fieldrrrrf�s
z%DeferredAttribute._check_parent_chainr)r#r$r%r`r6rkrfrrrrrazs

rac@steZdZedd��Zeejdd�dd���Zdd�Zd	d
�Z	e
dd��Zed
d��Zeddd��Z
eddd��ZdS)�RegisterLookupMixincCs|���|d�Sr)�get_lookups�get)r-�lookup_namerrr�_get_lookup�szRegisterLookupMixin._get_lookupN)�maxsizecCsdd�t�|�D�}|�|�S)NcSsg|]	}|j�di��qS)�
class_lookups)rdrt)�.0�parentrrr�
<listcomp>�sz3RegisterLookupMixin.get_lookups.<locals>.<listcomp>)�inspect�getmro�merge_dicts)r-rxrrrrs�s
zRegisterLookupMixin.get_lookupscC�Nddlm}|�|�}|durt|d�r|j�|�S|dur%t||�s%dS|S)Nr)�Lookup�output_field)�django.db.models.lookupsr�rvr?r��
get_lookupr )r
rur��foundrrrr���
zRegisterLookupMixin.get_lookupcCr)Nr)�	Transformr�)r�r�rvr?r��
get_transformr )r
rur�r�rrrr��r�z!RegisterLookupMixin.get_transformcCs i}t|�D]}|�|�q|S)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�drrrr~�szRegisterLookupMixin.merge_dictscCst|�D]}|j��qdSr)r+rs�cache_clearr,rrr�_clear_cached_lookups�s�z)RegisterLookupMixin._clear_cached_lookupscCs4|dur|j}d|jvri|_||j|<|��|S)Nrx)rurdrxr��r-�lookuprurrr�register_lookup�s

z#RegisterLookupMixin.register_lookupcCs|dur|j}|j|=dS)zn
        Remove given lookup from cls lookups. For use in tests only as it's
        not thread-safe.
        N)rurxr�rrr�_unregister_lookup�sz&RegisterLookupMixin._unregister_lookupr)r#r$r%�classmethodrv�	functools�	lru_cachersr�r��staticmethodr~r�r�r�rrrrrr�s 

		


	rrFcCs�|jsdS|jjr
|s
dS|r"|r|��|vrdS|s"|j|vr"dS|s)|jr)dS|rE|j|vrE|rE|j|vrEd|jjj|jf}t	|��dS)au
    Return True if this field should be used to descend deeper for
    select_related() purposes. Used by both the query construction code
    (sql.query.fill_related_selections()) and the model instance creation code
    (query.get_klass_info()).

    Arguments:
     * field - the field to be checked
     * restricted - a boolean field, indicating if the field list has been
       manually restricted using a requested clause)
     * requested - The select_related() dictionary.
     * load_fields - the set of fields to be loaded on this model
     * reverse - boolean, True if we are checking a reverse select related
    FzXField %s.%s cannot be both deferred and traversed using select_related at the same time.T)
�remote_field�parent_link�related_query_name�name�nullrernrl�object_namer)rb�
restricted�	requested�load_fields�reverse�msgrrr�select_related_descend�s&

�r�cCsVtdt|�d�D]}t�|d|��}||vr(||r(||||d�fSq	dS)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.
    �rN)Fr)�range�lenr�join)�lookup_parts�annotations�n�level_n_lookuprrr�refs_expression
s�r�cs,�fdd�}||�pt|dd�o||jj�S)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
    cs*�jj|jkp|j�j��vp�|��vSr)rl�concrete_model�get_parent_list)rp�rnrr�checks
�
�z-check_rel_lookup_compatibility.<locals>.checkroF)r=rnrl)rn�target_optsrbr�rr�r�check_rel_lookup_compatibilitys�r�c@s@eZdZdZe�d�dd�Zdd�Zdd�Zd	d
�Zdd�Z	d
S)�FilteredRelationz7Specify custom filtering in the ON clause of SQL joins.��	conditioncCs:|std��||_d|_t|t�std��||_g|_dS)Nzrelation_name cannot be empty.z*condition argument must be a Q() instance.)�
ValueError�
relation_name�aliasrr.r�r_)r
r�r�rrrr66s

zFilteredRelation.__init__cCs4t||j�stS|j|jko|j|jko|j|jkSr)rr�NotImplementedr�r�r�rIrrr�__eq__@s
�
�zFilteredRelation.__eq__cCs,t|j|jd�}|j|_|jdd�|_|S)Nr�)r�r�r�r�r_)r
�clonerrrr�IszFilteredRelation.clonecOstd��)zz
        QuerySet.annotate() only accepts expression-like arguments
        (with a resolve_expression() method).
        z0FilteredRelation.resolve_expression() is unused.)�NotImplementedError)r
r9r:rrrrZOsz#FilteredRelation.resolve_expressioncCs&|j}|j|jt|j�d�}|�|�S)N)rU)rT�build_filtered_relation_qr��setr_�compile)r
�compiler�
connectionrT�whererrr�as_sqlVs
zFilteredRelation.as_sqlN)
r#r$r%r`r.r6r�r�rZr�rrrrr�3s
	r�)F)r`r<r�r|r�collectionsr�django.core.exceptionsrr�django.db.models.constantsr�django.utilsr�django.utils.deprecationrr	rAr
�	Exceptionr(r+�Noder.rarrr�r�r�r�rrrr�<module>s*
A(
C%


https://t.me/RX1948 - 2025