https://t.me/AnonymousX5
Server : Apache
System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64
User : njnconst ( 1116)
PHP Version : 8.4.18
Disable Function : NONE
Directory :  /lib64/python2.7/site-packages/django/db/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib64/python2.7/site-packages/django/db/models/query.pyc
�
r�\c@s*dZddlZddlZddlZddlZddlmZddlmZddl	m
Z
mZmZm
Z
ddlmZddlmZddlmZmZmZmZdd	lmZdd
lmZddlmZddlmZdd
lmZdZ ej!Z!de"fd��YZ#de$fd��YZ%dej&e%�fd��YZ'de#fd��YZ(de(fd��YZ)de#fd��YZ*de#fd��YZ+dde,e,e,d�Z-dfd�Z.d e"fd!��YZ/e0e0e,d"�Z1d#�Z2d$�Z3d%�Z4dS(&sM
The main QuerySet implementation. This provides the public API for the ORM.
i����N(tsettings(t
exceptions(tconnectionstrouterttransactiont
DatabaseError(t
LOOKUP_SEP(t	AutoField(tQtselect_related_descendtdeferred_class_factorytInvalidQuery(t	Collector(tsql(t	partition(tsix(ttimezoneitQuerySetcBs�eZdZd@d@d@d�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd@d�Zd�Zd@dd�Zd@d�Zd@d�Zd�Zd�Zd�Zd�Zee_d�Zee_d�Zee_d�Z ee _d�Z!d�Z"d�Z#d �Z$d!d"�Z%d!d@d#�Z&d$�Z'd%�Z(d&�Z)d'�Z*d(�Z+d)�Z,d*�Z-d+�Z.d,�Z/d-�Z0d.�Z1d/�Z2d@d@d@d@d@d@d0�Z3d1�Z4d2�Z5d3�Z6d4�Z7d5�Z8e9e8�Z8e9d6��Z:d7�Z;d@e<d8�Z=d9�Z>d:�Z?d;�Z@d<�ZAd=�ZBd>�ZCd?�ZDeZERS(AsA
    Represents a lazy database lookup for a set of objects.
    cCsg||_||_|p'tj|j�|_d|_t|_t|_	g|_
t|_i|_dS(N(
tmodelt_dbR
tQuerytquerytNonet
_result_cachetFalset_sticky_filtert
_for_writet_prefetch_related_lookupst_prefetch_donet_known_related_objects(tselfRRtusing((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt__init__"s							cCse|j�}xR|jj�D]A\}}|dkrDd|j|<qtj||�|j|<qW|S(sD
        Deep copy of a QuerySet doesn't populate the cache
        RN(t	__class__t__dict__titemsRtcopytdeepcopy(Rtmemotobjtktv((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt__deepcopy__1scCs|j�|jj�}|S(s4
        Allows the QuerySet to be pickled.
        (t
_fetch_allR"R$(Rtobj_dict((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt__getstate__=s
cCs=t|td �}t|�tkr3d|d<nt|�S(Nis$...(remaining elements truncated)...i����(tlisttREPR_OUTPUT_SIZEtlentrepr(Rtdata((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt__repr__Fs
cCs|j�t|j�S(N(R+R0R(R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt__len__Ls
cCs|j�t|j�S(s
        The queryset iterator protocol uses three nested iterators in the
        default case:
            1. sql.compiler:execute_sql()
               - Returns 100 rows at time (constants.GET_ITERATOR_CHUNK_SIZE)
                 using cursor.fetchmany(). This part is responsible for
                 doing some column masking, and returning the rows in chunks.
            2. sql/compiler.results_iter()
               - Returns one row at time. At this point the rows are still just
                 tuples. In some cases the return values are converted to
                 Python values at this location (see resolve_columns(),
                 resolve_aggregate()).
            3. self.iterator()
               - Responsible for turning the rows into model objects.
        (R+titerR(R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt__iter__Ps
cCs|j�t|j�S(N(R+tboolR(R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt__nonzero__cs
c
Cs�t|tftj�s"t�nt|t�r>|dks�t|t�r�|jdksk|jdkr�|jdks�|jdks�td��|j	dk	r�|j	|St|t�rR|j
�}|jdk	r�t|j�}nd}|jdk	rt|j�}nd}|jj
||�|jrNt|�dd|j�S|S|j
�}|jj
||d�t|�dS(sE
        Retrieves an item or slice from the set of results.
        is#Negative indexing is not supported.Ni(t
isinstancetsliceRt
integer_typest	TypeErrortstartRtstoptAssertionErrorRt_clonetintRt
set_limitststepR.(RR(tqsR=R>((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt__getitem__gs*	-!	'cCsi|j|�t|t�r |St|t�r3|S|j�}|j|�|jj|jtj�|S(N(	t_merge_sanity_checkR9t
EmptyQuerySetR@t_merge_known_related_objectsRtcombineR
tAND(Rtothertcombined((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt__and__�s

cCsi|j|�t|t�r |St|t�r3|S|j�}|j|�|jj|jtj�|S(N(	RFR9RGR@RHRRIR
tOR(RRKRL((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt__or__�s

ccs�t}t|jjjr(|jj}nt|t�r@|}nd}|jj
}t|jj�}t|jj
�}|jj�}|s�|jjj}ng}|r5x�|jjj�D]r\}	}
|
dkr�|j}
ny*|	j||
kr	|j|	j�nWq�tk
r-|j|	j�q�Xq�Wnt|�}|t|pY|jjj�}d}
|r�|r�t�}
g}x@|D]8}	|	j|kr�|
j|	j�q�|j|	j�q�Wt|j|
�}n|j}|j}
|jjd|�}|r(t|
d|d|d|�}nx�|j�D]�}|rkt||||dt|��\}}nU|||!}|
r�|tt||���}n|
|�}||j _t|j _!|r�x1t"|�D] \}}t#||||�q�Wn|r8x5t"|�D]$\}}t#|||||�q
Wn|j$r�x�|j$j%�D]q\}	}t&||	j'��rxqQnt(||	j)��}y||}Wntk
r�qQXt#||	j|�qQWn|Vq5WdS(sc
        An iterator over the results from applying this QuerySet to the
        database.
        Rt	max_deptht	requestedt	only_loadtoffsetN(*RRtdbtfeaturestsupports_select_relatedRtselect_relatedR9tdictRRPR.textra_selecttaggregate_selecttget_loaded_field_namesRt_metatconcrete_fieldstget_concrete_fields_with_modeltnametappendtKeyErrorR0tsettaddtattnameR
tget_compilertget_klass_infotresults_itertget_cached_rowtzipt_statetaddingt	enumeratetsetattrRR#thasattrtget_cache_nametgetattrtget_attname(Rt
fill_cacheRQRPRYRZRRtfieldstload_fieldstfieldRtindex_starttaggregate_starttskipt	init_listt	model_clsRTtcompilert
klass_infotrowR't_trow_datatiR(t	aggregatetrel_objstpktrel_obj((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytiterator�s�	

	
		
	
cOs�|jjrtd��nx|D]}|||j<q"W|jj�}x6|j�D](\}}|j||j|dt�qUW|j	d|j
�S(s�
        Returns a dictionary containing the calculations (aggregation)
        over the current queryset

        If args is present the expression is passed as a kwarg using
        the Aggregate object's default alias.
        s/aggregate() + distinct(fields) not implemented.t
is_summaryR(Rtdistinct_fieldstNotImplementedErrort
default_aliastcloneR#t
add_aggregateRtTruetget_aggregationRT(RtargstkwargstargRtaliastaggregate_expr((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR�s
cCs2|jdk	rt|j�S|jjd|j�S(s�
        Performs a SELECT COUNT() and returns the number of records as an
        integer.

        If the QuerySet is already fully cached this simply returns the length
        of the cached results set to avoid multiple SELECT COUNT(*) calls.
        RN(RRR0Rt	get_countRT(R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytcounts
cOs�|j||�}|jj�r0|j�}nt|�}|dkrS|jdS|s{|jjd|jjj	��n|jj
d|jjj	|f��dS(sn
        Performs the query and returns a single object matching the given
        keyword arguments.
        iis!%s matching query does not exist.s2get() returned more than one %s -- it returned %s!N(tfilterRt
can_filtertorder_byR0RRtDoesNotExistR\tobject_nametMultipleObjectsReturned(RR�R�R�tnum((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytget(s		cKs5|j|�}t|_|jdtd|j�|S(s�
        Creates a new object with the given kwargs, saving it to the database
        and returning the created object.
        tforce_insertR(RR�RtsaveRT(RR�R'((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytcreate;s	cCs4|dks|dkst�|jjjr<td��n|sF|St|_t|j	}|jjj
}tjd|j	���|j
jr�|jjjr�|j|||�nxtd�|�\}}|r�|j|||�n|r*g|D]}t|t�s�|^q�}|j|||�nWdQX|S(s
        Inserts each of the instances into the database. This does *not* call
        save() on each of the instances, does not send any pre/post save
        signals, and does not set the primary key attribute if it is an
        autoincrement field.
        is$Can't bulk create an inherited modelRcSs
|jdkS(N(R�R(to((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt<lambda>bsN(RR?RR\tparentst
ValueErrorR�RRRTtlocal_concrete_fieldsRt commit_on_success_unless_managedRUt6can_combine_inserts_with_and_without_auto_increment_pkthas_auto_fieldt_batched_insertRR9R(Rtobjst
batch_sizet
connectionRstobjs_with_pktobjs_without_pktf((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytbulk_createEs&	
(c	Ksz|jdi�}|j�}xB|jjjD]1}|j|kr.|j|j�||j<q.q.Wy t|_|j	|�t
fSWn�|jjk
ruy{td�|j
�D��}|j|�|j|�}tjd|j��|jdtd|j�WdQX|tfSWqvtk
rqtj�}y|j	|�t
fSWqr|jjk
rmtj|�qrXqvXnXdS(s�
        Looks up an object with the given kwargs, creating one if necessary.
        Returns a tuple of (object, created), where created is a boolean
        specifying whether an object was created.
        tdefaultscss-|]#\}}t|kr||fVqdS(N(R(t.0R(R)((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pys	<genexpr>{sRR�N(tpopR$RR\RsRdR_R�RR�RR�RXR#tupdateRtatomicRTR�Rtsystexc_infoRtreraise(RR�R�tlookupR�tparamsR'R�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt
get_or_createks, 	

t-cCs�|pt|jjd�}t|�s3td��|jj�sNtd��|j�}|jjdd�|jj	dt
�|jjd||f�|j�S(s�
        Returns the latest object, according to the model's
        'get_latest_by' option or optional given field_name.
        t
get_latest_bys]earliest() and latest() require either a field_name parameter or 'get_latest_by' in the models2Cannot change a query once a slice has been taken.thighitforce_emptys%s%s(
RpRR\R7R?RR�R@RBtclear_orderingR�tadd_orderingR�(Rt
field_namet	directionR�R'((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt_earliest_or_latest�s	cCs|jd|dd�S(NR�R�t(R�(RR�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytearliest�scCs|jd|dd�S(NR�R�R�(R�(RR�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytlatest�scCsC|jr|n|jd�}y|dSWntk
r>dSXdS(sY
        Returns the first object of a query, returns None if no match is found.
        R�iN(torderedR�t
IndexErrorR(RRD((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytfirst�s

cCsI|jr|j�n|jd�}y|dSWntk
rDdSXdS(sX
        Returns the last object of a query, returns None if no match is found.
        s-pkiN(R�treverseR�R�R(RRD((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytlast�s
$
cCsf|jj�std��|s%iS|jd|�j�}tg|D]}|j�|f^qG�S(sh
        Returns a dictionary mapping each of the given IDs to the object with
        that ID.
        s+Cannot use 'limit' or 'offset' with in_bulktpk__in(RR�R?R�R�RXt_get_pk_val(Rtid_listRDR'((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytin_bulk�s	cCs�|jj�std��|j�}t|_t|j_t|j_|jj	dt�t
d|j�}|j|�|j
�d|_dS(s>
        Deletes the records in the current QuerySet.
        s+Cannot use 'limit' or 'offset' with delete.R�RN(RR�R?R@R�RRtselect_for_updateRWR�RRTtcollecttdeleteRR(Rt	del_queryt	collector((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR��s		

cCs tj|j�j||�dS(s�
        Deletes objects found from the given queryset in single direct SQL
        query. No signals are sent, and there is no protection for cascades.
        N(R
tDeleteQueryRt	delete_qs(RR((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt_raw_delete�scKs�|jj�std��t|_|jjtj�}|j|�t	j
d|j�� |j|j�j
d�}WdQXd|_|S(s
        Updates all elements in the current QuerySet, setting all the given
        fields to the appropriate values.
        s2Cannot update a query once a slice has been taken.RN(RR�R?R�RR�R
tUpdateQuerytadd_update_valuesRR�RTRetexecute_sqlRR(RR�Rtrows((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR��s		
!	cCs_|jj�std��|jjtj�}|j|�d|_|j	|j
�jd�S(s

        A version of update that accepts field objects instead of field names.
        Used primarily for model saving and not intended for use by general
        code (it requires too much poking around at model internals to be
        useful at that level).
        s2Cannot update a query once a slice has been taken.N(RR�R?R�R
R�tadd_update_fieldsRRReRTR�(RtvaluesR((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt_update�s	
	cCs2|jdkr%|jjd|j�St|j�S(NR(RRRthas_resultsRTR7(R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytexistsscCs t|j|j�t|_dS(N(tprefetch_related_objectsRRR�R(R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt_prefetch_related_objectsscGs|jdtdtd|�S(Ntklasstsetupt_fields(R@tValuesQuerySetR�(RRs((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR�sc
Os}|jdt�}|r4tdt|�f��n|r[t|�dkr[td��n|jdtdtd|d|�S(Ntflats/Unexpected keyword arguments to values_list: %sisH'flat' is not valid when values_list is called with more than one field.R�R�R�(R�RR<R.R0R@tValuesListQuerySetR�(RRsR�R�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytvalues_liststASCcCsX|d
kstd��|dks0td��|jdtd	td
|d|d|�S(s�
        Returns a list of date objects representing all available dates for
        the given field_name, scoped to 'kind'.
        tyeartmonthtdays/'kind' must be one of 'year', 'month' or 'day'.R�tDESCs''order' must be either 'ASC' or 'DESC'.R�R�t_field_namet_kindt_order(syearsmonthsday(sASCR�(R?R@tDateQuerySetR�(RR�tkindtorder((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytdatess		c
Cs�|dkstd��|dks0td
��tjrW|dkr]tj�}q]nd}|jdtdtd
|d|d|d|�S(s�
        Returns a list of datetime objects representing all available
        datetimes for the given field_name, scoped to 'kind'.
        R�R�R�thourtminutetsecondsK'kind' must be one of 'year', 'month', 'day', 'hour', 'minute' or 'second'.R�R�s''order' must be either 'ASC' or 'DESC'.R�R�R�R�R�t_tzinfo(syearsmonthsdayshoursminutessecond(sASCsDESCN(	R?RtUSE_TZRRtget_current_timezoneR@tDateTimeQuerySetR�(RR�R�R�ttzinfo((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt	datetimes(s			cCs|j�}|jj�|S(s,
        Returns an empty QuerySet.
        (R@Rt	set_empty(RR�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytnone9s
cCs
|j�S(s�
        Returns a new QuerySet that is a copy of the current one. This allows a
        QuerySet to proxy for a model manager in some cases.
        (R@(R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytallEscOs|jt||�S(sb
        Returns a new QuerySet instance with the args ANDed to the existing
        set.
        (t_filter_or_excludeR(RR�R�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR�LscOs|jt||�S(sd
        Returns a new QuerySet instance with NOT (args) ANDed to the existing
        set.
        (RR�(RR�R�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytexcludeSscOsv|s|r*|jj�s*td��n|j�}|rY|jjt||��n|jjt||��|S(Ns2Cannot filter a query once a slice has been taken.(RR�R?R@tadd_qR(RtnegateR�R�R�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyRZscCsRt|t�st|d�r>|j�}|jj|�|S|jd|�SdS(so
        Returns a new QuerySet instance with filter_obj added to the filters.

        filter_obj can be a Q object (or anything with an add_to_query()
        method) or a dictionary of keyword lookup arguments.

        This exists to support framework features such as 'limit_choices_to',
        and usually it will be more natural to use other methods.
        tadd_to_queryN(R9RRnR@RRRR(Rt
filter_objR�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytcomplex_filterfs

cKsC|jdt�}|j�}t|_t|j_||j_|S(sj
        Returns a new QuerySet instance that will select objects with a
        FOR UPDATE lock.
        tnowait(R�RR@R�RRR�tselect_for_update_nowait(RR�R	R'((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR�ws	cOs�d|kr%tjdtdd�n|jdd�}|rYtdt|�f��n|j�}|d	kr�t|j	_
n:|r�|r�td��n|j	j|�nt|j	_
|r�||j	_
n|S(
s
        Returns a new QuerySet instance that will select related objects.

        If fields are specified, they must be ForeignKey fields and only those
        related objects are included in the selection.

        If select_related(None) is called, the list is cleared.
        tdepthsRThe "depth" keyword argument has been deprecated.
Use related field names instead.t
stackleveliis2Unexpected keyword arguments to select_related: %ss7Cannot pass both "depth" and fields to select_related()N(N(twarningstwarntDeprecationWarningR�R<R.R@RRRRWtadd_select_relatedR�RP(RRsR�RR'((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyRW�s$		cGs8|j�}|dkr$g|_n|jj|�|S(sh
        Returns a new QuerySet instance that will prefetch the specified
        Many-To-One and Many-To-Many related objects when the QuerySet is
        evaluated.

        When prefetch_related() is called more than once, the list of lookups to
        prefetch is appended to. If prefetch_related(None) is called, the
        the list is cleared.
        N(N(R@RRtextend(RtlookupsR�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytprefetch_related�s

c	Osx@|D]8}|j|kr2td|j��n|||j<qWt|dd�}|dkr|t|jjj��}nx-|D]%}||kr�td|��q�q�W|j�}|j	t
|��x9|j�D]+\}}|jj
||j|dt�q�W|S(s�
        Return a query set in which the returned objects have been annotated
        with data aggregated from related fields.
        sQThe named annotation '%s' conflicts with the default name for another annotation.R�s8The annotation '%s' conflicts with a field on the model.R�N(R�R�RpRRbRR\tget_all_field_namesR@t_setup_aggregate_queryR.R#RR�R(	RR�R�R�tnamesR�R'R�R�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytannotate�s$

cGsN|jj�std��|j�}|jjdt�|jj|�|S(sL
        Returns a new QuerySet instance with the ordering changed.
        s3Cannot reorder a query once a slice has been taken.R�(RR�R?R@R�RR�(Rtfield_namesR'((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR��s	cGs;|jj�std��|j�}|jj|�|S(sY
        Returns a new QuerySet instance that will select only distinct results.
        s:Cannot create distinct fields once a slice has been taken.(RR�R?R@tadd_distinct_fields(RRR'((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytdistinct�s
	cCsJ|jj�std��|j�}|jj||||||�|S(s8
        Adds extra SQL fragments to the query.
        s1Cannot change a query once a slice has been taken(RR�R?R@t	add_extra(RtselecttwhereR�ttablesR�t
select_paramsR�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytextra�s
	cCs#|j�}|jj|j_|S(s8
        Reverses the ordering of the QuerySet.
        (R@Rtstandard_ordering(RR�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR��scGs<|j�}|dkr(|jj�n|jj|�|S(sU
        Defers the loading of data for certain fields until they are accessed.
        The set of fields to defer is added to any existing set of deferred
        fields. The only exception to this is if None is passed in as the only
        parameter, in which case all deferrals are removed (None acts as a
        reset option).
        N(N(R@RRtclear_deferred_loadingtadd_deferred_loading(RRsR�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytdefer�s
cGs;|dkrtd��n|j�}|jj|�|S(s�
        Essentially, the opposite of defer. Only the fields passed into this
        method and that are not already specified as deferred are loaded
        immediately when the queryset is evaluated.
        s*Cannot pass None as an argument to only().N(N(RR<R@Rtadd_immediate_loading(RRsR�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytonlys
cCs|j�}||_|S(sY
        Selects which database this QuerySet should excecute its query against.
        (R@R(RR�R�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyRs	cCsF|jjs|jjrtS|jjr>|jj�jr>tStSdS(s�
        Returns True if the QuerySet is ordered -- i.e. has an order_by()
        clause or a default ordering on the model.
        N(Rtextra_order_byR�R�tdefault_orderingtget_metatorderingR(R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR�"s
cCs;|jr"|jp!tj|j�S|jp:tj|j�S(sCReturn the database that will be used if this query is executed now(RRRtdb_for_writeRtdb_for_read(R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyRT/s	cCs�|s
dSt|jj}|p8t|j||�d�}x`gtdt|�|�D]}||||!^qWD](}|jjj	|d|d|j�qrWdS(s�
        A little helper method for bulk_insert to insert the bulk one batch
        at a time. Inserts recursively a batch from the front of the bulk and
        then _batched_insert() the remaining objects again.
        NiiRsR(
RRTtopstmaxtbulk_batch_sizetrangeR0Rt
_base_managert_insert(RR�RsR�R-R�tbatch((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR�9s!7cKs�|dkr|j}n|jj�}|jr<t|_n|d|jd|d|j�}|j	|_	|j
|_
|j|_|jj
|�|r�t|d�r�|j�n|S(NRRRt_setup_query(RR!RR�RR�tfilter_is_stickyRRRRRR"R�RnR4(RR�R�R�Rtc((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR@Hs	!

cCsK|jdkr't|j��|_n|jrG|jrG|j�ndS(N(RRR.R�RRR�(R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR+WscCs
t|_|S(s
        Indicates that the next filter call and the one following that should
        be treated as a single filter. This is only important when it comes to
        determining when to reuse tables for many-to-many filters. Required so
        that we can filter naturally on the results of related managers.

        This doesn't return a clone of the current QuerySet (it returns
        "self"). The method is only used internally and should be immediately
        followed by a filter() that does create a clone.
        (R�R(R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt_next_is_sticky]s	cCsdS(s�
        Checks that we are merging two comparable QuerySet classes. By default
        this does nothing, but see the ValuesQuerySet for an example of where
        it's useful.
        N((RRK((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyRFkscCs@x9|jj�D](\}}|jj|i�j|�qWdS(sX
        Keep track of all known related objects from either QuerySet instance.
        N(RR#t
setdefaultR�(RRKRutobjects((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyRHsscCsd|jj}|jjdkr`g|jD]}|j^q(}|jj|t�|jj	�ndS(s_
        Prepare the query for computing a result that contains aggregate annotations.
        N(
RR\Rtgroup_byRR]Rdt
add_fieldsRtset_group_by(Rt
aggregatestoptsR�R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyRzs
cCs|S(N((R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt_prepare�scCsZ|jd�}|jdks1|t|jkrJ|jjd|�j�Std��dS(sO
        Returns the internal query's SQL and parameters (as a tuple).
        R�R�s2Can't do subqueries with queries on different DBs.N(R�RRRRRet
as_nested_sqlR�(RR�R'((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt_as_sql�s"N(Ft__name__t
__module__t__doc__RR R*R-R3R4R6R8RERMROR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�talters_dataR�R�R�R�R�R�R�R�R�RRR�RRRR�RWRRR�RR R�R$R&RR�tpropertyRTR�RR@R+R7RFRHRR?RAtvalue_annotation(((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyRs�											f		
		
&		
	
								
						
							
					

					
						
		tInstanceCheckMetacBseZd�ZRS(cCs
|jj�S(N(Rtis_empty(Rtinstance((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt__instancecheck__�s(RBRCRK(((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyRH�sRGcBseZdZd�ZRS(s�
    Marker class usable for checking if a queryset is empty by .none():
        isinstance(qs.none(), EmptyQuerySet) -> True
    cOstd��dS(Ns#EmptyQuerySet can't be instantiated(R<(RR�R�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR �s(RBRCRDR (((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyRG�sR�cBs_eZd�Zd�Zd�Zd�Zd	ed�Zd�Z	d�Z
d�Zd�ZRS(
cOs)tt|�j||�t|j_dS(N(tsuperR�R RRRW(RR�R�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR �sccsyt|jj�}|j}t|jj�}|||}x7|jj|j�j�D]}tt	||��VqWWdS(N(
R.RRYRRZReRTRgRXRi(Rtextra_namesRtaggregate_namesRR}((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR��s	"cCstd��dS(NsAQueries with .values() or .values_list() applied can't be deleted(R<(R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR��scCs�|jj�|jj�|jr�g|_g|_|jjrd|jjrdt|j�|_	q$t
|j_g|_	x�|jD]`}||jjkr�|jj|�q�||jj
kr�|jj|�q�|j	j|�q�Wn:d|_g|jjjD]}|j^q|_	d|_g|j_|jdk	rU|jj|j�n|jj|j	t�|jdk	r�|jj|j�ndS(s�
        Constructs the field_names list that the values query will be
        retrieving.

        Called by the _clone() method after initializing the rest of the
        instance.
        N(RR"tclear_select_fieldsR�RMRNR R=R.RRtdefault_colsR`RZRRR\R]RdRtset_extra_maskR;R�tset_aggregate_mask(RR�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR4�s0

					(	cKs�tt|�j||�}t|d�s:|j|_n|j|_|j|_|j|_|r�t|d�r�|j�n|S(sH
        Cloning a ValuesQuerySet preserves the current fields.
        R�R4(	RLR�R@RnR�RRMRNR4(RR�R�R�R6((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR@�s
cCs�tt|�j|�t|j�t|j�ksdt|j�t|j�ksd|j|jkr}td|jj	��ndS(Ns?Merging '%s' classes must involve the same values in each case.(
RLR�RFRbRMRRNR<R!RB(RRK((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyRF�scCs\|jj�|jdk	rB|jj|�|jj|j�ntt|�j|�dS(s_
        Prepare the query for computing a result that contains aggregate annotations.
        N(	RR<RNRRRRRLR�R(RR=((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR�s

cCs�|jrt|j�dksC|jr\t|jjj�dkr\td|jj��n|j�}|j	dks�|t|j	kr�|jj
d|�j�Std��dS(s_
        For ValuesQuerySet (and subclasses like ValuesListQuerySet), they can
        only be used as nested queries if they're already set up to select only
        a single field (in which case, that is the field column that is
        returned). This differs from QuerySet.as_sql(), where the column to
        select is set up by Django.
        is.Cannot use a multi-field %s as a filter value.R�s2Can't do subqueries with queries on different DBs.N(R�R0RR\RsR<R!RBR@RRRRReR@R�(RR�R'((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyRAs%"cCs`|jrt|j�dksC|jr\t|jjj�dkr\td|jj��n|S(s�
        Validates that we aren't trying to do a query like
        value__in=qs.values('value1', 'value2'), which isn't valid.
        is.Cannot use a multi-field %s as a filter value.(R�R0RR\RsR<R!RB(R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR?s
%N(
RBRCR R�R�R4RRR@RFRRAR?(((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR��s				,			R�cBseZd�Zd�ZRS(c	cs�|jrPt|j�dkrPx\|jj|j�j�D]}|dVq:Wn-|jjr�|jjr�x|jj|j�j�D]}t	|�Vq�Wn�t
|jj�}|j}t
|jj�}|||}|jrt
|j�g|D]}||jkr�|^q�}n|}xZ|jj|j�j�D]=}tt
||��}t	g|D]}||^qa�Vq<WdS(Nii(R�R0R�RReRTRgRYRZttupleR.RRXRi(	RR}RMRRNRR�RsR2((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR�*s ""		8"cOs=tt|�j||�}t|d�s9|j|_n|S(NR�(RLR�R@RnR�(RR�R�R�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR@Fs(RBRCR�R@(((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR�)s	R�cBs)eZd�Zd�Zded�ZRS(cCs|jj|j�j�S(N(RReRTRg(R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR�OscCs]|jj�|jjdtjdt�|_g|j_|jj|j|j	|j
�dS(s�
        Sets up any special features of the query attribute.

        Called by the _clone() method after initializing the rest of the
        instance.
        R�R�N(RR"R�R
t	DateQueryR�Rt
add_selectR�R�R�(R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR4Rs
!cKs\tt|�j|t|�}|j|_|j|_|rXt|d�rX|j�n|S(NR4(RLR�R@RR�R�RnR4(RR�R�R�R6((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR@^s
N(RBRCR�R4RRR@(((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR�Ns		R�cBs)eZd�Zd�Zded�ZRS(cCs|jj|j�j�S(N(RReRTRg(R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR�hscCsf|jj�|jjdtjdtd|j�|_g|j_|jj|j	|j
|j�dS(s�
        Sets up any special features of the query attribute.

        Called by the _clone() method after initializing the rest of the
        instance.
        R�R�R�N(RR"R�R
t
DateTimeQueryR�R�RRUR�R�R�(R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR4ks
*cKshtt|�j|t|�}|j|_|j|_|j|_|rdt|d�rd|j�n|S(NR4(	RLR�R@RR�R�R�RnR4(RR�R�R�R6((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR@ws
N(RBRCR�R4RRR@(((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR�gs		icCs�|r"|dkr"||kr"dS|r�|j|�p=t�}xE|jj�D]+}|j|�}|rP|j|�qPqPWnd}|rCt�}	g}
xp|jj�D]_\}}|r�|r�t||�r�q�q�|j|kr�|	j	|j
�q�|
j|j
�q�Wt|
�}
|	r:t
||	�}|
}qd	}n�t|jj�}
|r�t|jj�t|jj�kr�g|jj�D]}t||�s�|^q�}|j|�g|jjD]}|j|kr�|j
^q�}t|�}
n|
t|jj�krd
}n|dk	}g}x�|jjD]{}t||||�r=|rn||j}nd}t|jjd|d|dd|d|�}|j||f�q=q=Wg}|r�x�|jj�D]�}|jjr�t|j|||j|j�dt�r�||jj�}t|j|�r?|nd}t|jd|d|dd|d|d|�}|j|j|f�q�q�Wn|r�|j|jjj
�}n|jj�}|||
|||fS(s�
    Helper function that recursively returns an information for a klass, to be
    used in get_cached_row.  It exists just to compute this information only
    once for entire queryset. Otherwise it would be computed for each row, which
    leads to poor perfomance on large querysets.

    Arguments:
     * klass - the class to retrieve (and instantiate)
     * max_depth - the maximum depth to which a select_related()
       relationship should be explored.
     * cur_depth - the current depth in the select_related() tree.
       Used in recursive calls to determin if we should dig deeper.
     * requested - A dictionary describing the select_related() tree
       that is to be retrieved. keys are field names; values are
       dictionaries describing the keys on that related object that
       are themselves to be select_related().
     * only_load - if the query has had only() or defer() applied,
       this is the list of field names that will be returned. If None,
       the full field list for `klass` can be assumed.
     * from_parent - the parent model used to get to this model

    Note that when travelling from parent to child, we will only load child
    fields which aren't in the parent.
    RPt	cur_depthiRQRRR�tfrom_parentN(((RR�RbR\tget_parent_listR�R^t
issubclassR_RcRdR`R0R
R]R�RRsR	Rftrelttotget_all_related_objectsRutuniqueR�trelated_query_nametindexR�tpk_index(R�RPRWRQRRRXRttparentRsRxRyRuRtfield_countRtptnon_seen_modelsR�t
restrictedtrelated_fieldstnextR|treverse_related_fieldsR�tpk_idx((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyRf�sr			*
	 c	Cs"|dkrdS|\}}}}	}
}||||!}||dksY||dkrbd}
np|r�t|�}x1|D])\}}|j|j�|j|�q{W|tt||���}
n||�}
|
r�||
j_t|
j_	n|||}x�|	D]�\}}t
||||�}|r|\}}|
dk	r`t|
|j�|�n|j
r�|dk	r�t||jj�|
�q�qqWx}|
D]u\}}g}x^|djj�D]I\}}|dk	r�t|
|�r�|j|t|
|j�f�q�q�Wt
||||d|�}|r�|\}}|
dk	rgt|
|jj�|�n|dk	rt||j�|
�x�|D]z\}}|jr�t||jt|
|j��y/t|
|j��}t||j�|�Wq
tk
rq
Xq�q�Wqq�q�W|
|fS(sS
    Helper function that recursively returns an object with the specified
    related attributes already populated.

    This method may be called recursively to populate deep select_related()
    clauses.

    Arguments:
         * row - the row of data returned by the database cursor
         * index_start - the index of the row at which data for this
           object is known to start
         * offset - the number of additional fields that are known to
           exist in row for `klass`. This usually means the number of
           annotated results on `klass`.
         * using - the database alias on which the query is being executed.
         * klass_info - result of the get_klass_info function
         * parent_data - parent model data in format (field, value). Used
           to populate the non-local fields of child models.
    R�itparent_dataN(RR.R`RdRXRiRjRTRRkRhRmRoR^trelatedR\tget_fields_with_modelR9RpR[tAttributeError(R}RvRR|RSRkR�RRcRgRiRjRsR't	rel_fieldtvaluet	index_endR�t
cached_rowR�t	rel_modelR~t
cached_obj((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyRh�s^ 	# &		
tRawQuerySetcBsweZdZd	d	d	d	d	d�Zd�Zd�Zd�Zed��Z	d�Z
ed��Zed��ZRS(
sp
    Provides an iterator which converts the results of raw SQL queries into
    annotated model instances.
    cCsg||_||_||_|p?tjd|d|jd|�|_|pNd|_|p]i|_dS(NR
RR�((	t	raw_queryRRR
tRawQueryRTRR�ttranslations(RRvRRR�RxR((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR ]s			*ccs�i}g}|j}t|jjd�|jt||�}t|d�}t|j�}xVt|j�D]E\}}||j	kr�|||j	|j
<ql|j||f�qlWt�}	x9|j
jjD](}
|
j
|kr�|	j|
j
�q�q�W|	r<|j
jjj
|	kr'td��nt|j
|	�}n=|j
}g}x+|j
jjD]}
|j||
j
�q[W|r�g|jD]}
|j	j|
d�^q�}nx�|D]�}|r�|j||�}n|	ri}x+tj|�D]\}}||||<q�W||�}n)g|D]}||^q%}||�}|r{x+|D] \}}t||||�qTWn||j_t|j_|Vq�WdS(NtSQLCompilertresolve_columnss&Raw query must include the primary key(RTRR-R{RRnR5Rltcolumnstmodel_fieldsRdR`RbRR\RsRcR�RR
R�RRzRt	iteritemsRmRjRRk(Rtmodel_init_field_namestannotation_fieldsRTR{tneed_resolv_columnsRtpostcolumnRxRuRztmodel_init_field_posR6RsR�tmodel_init_kwargsRdRJtmodel_init_args((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR6fsR			.
cCsK|j}|jrC|t|jd�r0|jnt|j�}nd|S(Ntkeyss<RawQuerySet: %r>(RvR�RnRS(Rttext((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR3�s		1cCst|�|S(N(R.(RR(((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyRE�scCs|jptj|j�S(sCReturn the database that will be used if this query is executed now(RRR,R(R((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyRT�scCsCt|jd|jd|jjd|�d|jd|jd|�S(s^
        Selects which database this Raw QuerySet should excecute it's query against.
        RRRR�Rx(RuRvRRR�R�Rx(RR�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR�scCs�t|d�s{|jj�|_xW|jj�D]C\}}y#|jj|�}||j|<Wq1tk
rsq1Xq1Wn|jS(sg
        A list of model field names in the order they'll appear in the
        query results.
        t_columns(RnRtget_columnsR�RxR#R`R�(Rt
query_namet
model_nameR`((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR{�s
cCstt|d�smt|jjj}i|_x?|jjjD]+}|j	�\}}||j||�<q;Wn|jS(sC
        A dict mapping column names to model field names.
        t
_model_fields(
RnRRTt
introspectionttable_name_converterR�RR\Rstget_attname_column(Rt	converterRuR_R�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR|�s	N(
RBRCRDRR R6R3RERFRTRR{R|(((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyRuXs		C				cCs>tj|�}|j||d|�|jd|�j|�S(s�
    Inserts a new record for the given model. This provides an interface to
    the InsertQuery class and is how Model.save() is implemented. It is not
    part of the public API.
    trawR(R
tInsertQueryt
insert_valuesReR�(RR�Rst	return_idR�RR((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pytinsert_query�sc
Cs�t|�dkrdS|dj}t�}i}g}t�}tj||�}x�|D]|}||krrqZn|j|�|}	|jt�}
x?t|
�D]1\}}t|	�dkr�Pntj	|
d|d!�}
|
|kr�||
}	q�nt
}xH|	D]@}t|d�sy
i|_WqFt
k
rBt}PqFXqqW|sTPn|	d}t||�\}}}}|s�t
d||jj|f��n|t|
�dkr�|dkr�td|��n|dk	ri|rit|	||�\}	}||ko||ksYx0|D](}tj	|
|g�}|j|�q W|	||
<n|j|�q�g}xZ|	D]R}yt||�}Wntjk
r�qvnX|dkr�qvn|j|�qvW|}	q�WqZWdS(s�
    Helper function for prefetch_related functionality

    Populates prefetched objects caches for a list of results
    from a QuerySet
    iNit_prefetched_objects_cachesQCannot find '%s' on %s object, '%s' is an invalid parameter to prefetch_related()so'%s' does not resolve to a item that supports prefetching - this is an invalid parameter to prefetch_related().(R0R!Rbt	itertoolstchainRctsplitRRltjoinR�RnR�RnRtget_prefetcherRBRR�tprefetch_one_levelR`RpRtObjectDoesNotExist(tresult_cachetrelated_lookupsRtdone_lookupstdone_queriestauto_lookupstfollowed_descriptorstall_lookupsR�tobj_listtattrstleveltattrtcurrent_lookuptgood_objectsR't	first_objt
prefetchert
descriptort
attr_foundt
is_fetchedtadditional_prlR�tnew_prltnew_obj_listtnew_obj((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR��st
		






"


	
cCs�d}t}t}t|j|d�}|dkrcyt||�}t}Wq�tk
r_q�Xnft}|r�t|d�r�|}|j|�r�t}q�q�t||�}t|d�r�|}q�n||||fS(s�
    For the attribute 'attr' on the given instance, finds
    an object that has a get_prefetch_queryset().
    Returns a 4 tuple containing:
    (the object with get_prefetch_queryset (or None),
     the descriptor object representing this relationship (or None),
     a boolean that is False if the attribute was not found at all,
     a boolean that is True if the attribute has already been fetched)
    tget_prefetch_querysetN(RRRpR!R�RnRnt	is_cached(RJR�R�R�R�trel_obj_descriptorR�((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR�as(


cCs |j|�\}}}}}t|dg�}|rBg|_nt|�}	i}
x3|	D]+}||�}|
j|g�j|�q[Wx�|D]�}
||
�}|
j|g�}|r�t|
||r�|dnd�q�t|
|�j	�}||_
t|_||
j
|<q�W|	|fS(sU
    Helper function for prefetch_related_objects

    Runs prefetches on all instances using the prefetcher object,
    assigning results to relevant caches in instance.

    The prefetched objects are returned, along with any additional
    prefetches that must be done due to prefetch_related lookups
    found from default managers.
    RiN(R�RpRR.R8R`R�RmRRRR�RR�(t	instancesR�Rdtrel_qstrel_obj_attrt
instance_attrtsinglet
cache_nameR�tall_related_objectst
rel_obj_cacheR�trel_attr_valR'tinstance_attr_valtvalsRD((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyR��s&

#		(5RDR$R�R�R
tdjango.confRtdjango.coreRt	django.dbRRRRtdjango.db.models.constantsRtdjango.db.models.fieldsRtdjango.db.models.query_utilsRR	R
Rtdjango.db.models.deletionRtdjango.db.modelsR
tdjango.utils.functionalRtdjango.utilsRRR/tEmptyResultSettobjectRttypeRHtwith_metaclassRGR�R�R�R�RRfRhRuRR�R�R�R�(((s8/tmp/pip-install-XxeQeY/django/django/db/models/query.pyt<module>sH""	���y	�%	rc�	t	+

https://t.me/AnonymousX5 - 2025