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__/indexes.cpython-310.pyc
o

3�a,�@s�ddlmZmZddlmZmZmZmZmZddl	m
Z
ddlmZddl
mZddlmZdgZGdd�d�ZGd	d
�d
e�ZdS)�)�names_digest�split_identifier)�Col�ExpressionList�F�Func�OrderBy��Collate)�Q)�Query)�	partition�Indexc@szeZdZdZdZddddddd�dd�Zedd	��Zd
d�Zdd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)r�idx��N)�fields�name�
db_tablespace�	opclasses�	condition�includecGsn|r|std��t|td�tf�std��|r|std��t|ttf�s(td��t|ttf�s3td��|s;|s;td��|rC|rCtd��|rK|sKtd��|rS|rStd	��|rat|�t|�kratd
��|rptdd�|D��sptd
��|rx|sxtd��t|td�ttf�s�td��t|�|_dd�|jD�|_	|p�d|_
||_||_||_
|r�t|�nd|_tdd�|D��|_dS)Nz(An index must be named to use opclasses.z%Index.condition must be a Q instance.z(An index must be named to use condition.z%Index.fields must be a list or tuple.z(Index.opclasses must be a list or tuple.z@At least one field or expression is required to define an index.z4Index.fields and expressions are mutually exclusive.z*An index must be named to use expressions.zgIndex.opclasses cannot be used with expressions. Use django.contrib.postgres.indexes.OpClass() instead.zGIndex.fields and Index.opclasses must have the same number of elements.css�|]}t|t�VqdS�N)�
isinstance�str)�.0�fieldrr�:/usr/lib/python3/dist-packages/django/db/models/indexes.py�	<genexpr>7��z!Index.__init__.<locals>.<genexpr>z8Index.fields must contain only strings with field names.zA covering index must be named.z&Index.include must be a list or tuple.cSs.g|]}|�d�r|dd�dfn|df�qS)�-�N�DESC�)�
startswith�r�
field_namerrr�
<listcomp>?s ��z"Index.__init__.<locals>.<listcomp>r#rcss&�|]}t|t�r
t|�n|VqdSr)rrr�r�
expressionrrrrHs
��
�)�
ValueErrorr�typer�list�tuple�len�allr�
fields_ordersrrrrr�expressions)�selfrrrrrrr1rrr�__init__sX
���
�
�zIndex.__init__cCs
t|j�Sr)�boolr1�r2rrr�contains_expressionsM�
zIndex.contains_expressionscs`|jdurdSt|dd�}|�|j�}|j�jd�}|�|�j�\}}|t�fdd�|D��S)NF)�model�
alias_cols)�
connectionc3s�|]}��|�VqdSr)�quote_value)r�p��
schema_editorrrrXrz+Index._get_condition_sql.<locals>.<genexpr>)rr�build_where�get_compilerr:�as_sqlr-)r2r8r>�query�where�compiler�sql�paramsrr=r�_get_condition_sqlQs
zIndex._get_condition_sqlr#c
s��fdd�|jD�}|��|�}|jr:g}|jD]}t|�}	|	�|j�|�|	�qt|��t	�dd��}
d}d}n�fdd�|j
D�}dd�|j
D�}d}
|j�f||j||j
||j|||
d�	|��S)Ncsg|]	}�j�|�j�qSr��_meta�	get_field�columnr%�r8rrr'[sz$Index.create_sql.<locals>.<listcomp>F)r9csg|]
\}}�j�|��qSr)rIrJ)rr&�_rLrrr'is
��cSsg|]}|d�qS)r!r)r�orderrrrr'm�)	rr�usingr�col_suffixesrrrr1)rrGr1�IndexExpression�set_wrapper_classesr:�appendr�resolve_expressionrr0�_create_index_sqlrrr)
r2r8r>rP�kwargsrr�index_expressionsr)�index_expressionr1rrQrrLr�
create_sqlZs8

�
����zIndex.create_sqlcKs|j||jfi|��Sr)�_delete_index_sqlr)r2r8r>rWrrr�
remove_sqlvszIndex.remove_sqlcCs�d|jj|jjf}|�dd�}d|ji}|jr|j|d<|jdur'|j|d<|jr/|j|d<|jr7|j|d<|j	r?|j	|d	<||j
|fS)
Nz%s.%szdjango.db.models.indexeszdjango.db.modelsrrrrrr)�	__class__�
__module__�__name__�replacerrrrrrr1)r2�pathrWrrr�deconstructys






zIndex.deconstructcCs|��\}}}|j|i|��S)zCreate a copy of this Index.)rbr])r2rM�argsrWrrr�clone�szIndex.clonecs�t�jj�\}}�fdd�|jD�}dd�t||j�D�}|g||jg}d|dd�|ddd�d	t|d
di�|jff|_t|j�|j	ksNJd��|jdd
ks\|jd�
�rhd|jdd�|_dSdS)a
        Generate a unique name for the index.

        The name is divided into 3 parts - table name (12 chars), field name
        (8 chars) and unique hash + suffix (10 chars). Each part is made to
        fit its size by truncating the excess length.
        csg|]\}}�j�|�j�qSrrH)rr&rNrLrrr'�sz-Index.set_name_with_model.<locals>.<listcomp>cSs$g|]\}\}}|rdnd|�qS)z-%sz%sr)r�column_namer&rNrrrr'�s
��z%s_%s_%sN�r�z%s_%s�length�zVIndex too long for multiple database support. Is self.suffix longer than 3 characters?rMzD%sr!)rrI�db_tabler0�zip�suffixrrr.�max_name_length�isdigit)r2r8rM�
table_name�column_names�column_names_with_order�	hash_datarrLr�set_name_with_model�s"
�
���zIndex.set_name_with_modelc
Cs�d|jj|js	dndd�|j�|jsdndd�dd�|jD��|jdur(dnd|j|js1dnd	d�|j�|js?dfSd
d�|j�fS)Nz<%s:%s%s%s%s%s>r#z fields='%s'�, z expressions='%s'cS�g|]}t|��qSr)rr(rrrr'�s�z"Index.__repr__.<locals>.<listcomp>z
 condition=%sz
 include='%s'z opclasses='%s')r]r_r�joinr1rrrr5rrr�__repr__�s���zIndex.__repr__cCs |j|jkr|��|��kStSr)r]rb�NotImplemented)r2�otherrrr�__eq__�szIndex.__eq__)r#)r_r^�__qualname__rlrmr3�propertyr6rGrZr\rbrdrsrwrzrrrrrs(�<

	csVeZdZdZdZeefZddd�Ze	dd��Z
							d�fd
d�	Zdd
�Z�Z
S)rRz7Order and wrap expressions for CREATE INDEX statements.z%(expressions)sNcCs.|r|jjrtdd�|jD��|_dSdSdS)NcSsg|]}|tur|�qSrr	�r�wrapper_clsrrrr'�s
�z7IndexExpression.set_wrapper_classes.<locals>.<listcomp>)�features�collate_as_index_expressionr-�wrapper_classes)r2r:rrrrS�s
��z#IndexExpression.set_wrapper_classescGs
||_dSr)r�)�clsr�rrr�register_wrappers�r7z!IndexExpression.register_wrappersTFcs^t����}t�fdd�|�\}}dd�|D�}	t|	�tt|	��kr1tdd�dd��jD����|dt|�d�|krLtd	d�d
d��jD����|d}
|
�|||||�}t	|t
�sdt|
dd�}
|r�t|�fd
d�d�}dd�|D�}t
|dd��D]\}}
|
�||dg�q|d�|
g���|dg�n��|
g�t��|||||�S)Ncst|�j�Sr)rr�)�er5rr�<lambda>�sz4IndexExpression.resolve_expression.<locals>.<lambda>cSrur)r+�r�wrapperrrrr'�rOz6IndexExpression.resolve_expression.<locals>.<listcomp>zAMultiple references to %s can't be used in an indexed expression.rtcS�g|]}|j�qSr�r{r}rrrr'���r!z8%s must be topmost expressions in an indexed expression.cSr�rr�r}rrrr'�r�z(%(expressions)s))�templatecs�j�t|��Sr)r��indexr+)�wr5rrr��s)�keycSsg|]}|���qSr)�copyr�rrrr'�rO���r)r,�flattenr
r.�setr*rvr�rUrrr�sorted�	enumerate�set_source_expressions�super)r2rB�allow_joins�reuse�	summarize�for_saver1rX�wrappers�
wrapper_types�root_expression�resolve_root_expression�ir��r]r5rrU�sX
�
���
����

�z"IndexExpression.resolve_expressioncKs|j||fi|��Sr)rA)r2rDr:�
extra_contextrrr�	as_sqlite	szIndexExpression.as_sqliter)NTNFF)r_r^r{�__doc__r�rr
r�rS�classmethodr�rUr��
__classcell__rrr�rrR�s
	
�:rRN)�django.db.backends.utilsrr�django.db.models.expressionsrrrrr�django.db.models.functionsr
�django.db.models.query_utilsr�django.db.models.sqlr�django.utils.functionalr
�__all__rrRrrrr�<module>s3

https://t.me/RX1948 - 2025