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/contrib/postgres/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/contrib/postgres/__pycache__/constraints.cpython-310.pyc
o

3�a��@sbddlmZddlmZmZddlmZmZmZddl	m
Z
ddlmZdgZ
Gdd�de
�ZdS)	�)�NotSupportedError)�	Statement�Table)�
Deferrable�F�Q)�BaseConstraint)�Query�ExclusionConstraintcs~eZdZdZdddddd��fdd�
Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
�fdd�Z�fdd�Zdd�Z
�ZS)r
zdCONSTRAINT %(name)s EXCLUDE USING %(index_type)s (%(expressions)s)%(include)s%(where)s%(deferrable)sN�)�
index_type�	condition�
deferrable�include�	opclassescs2|r|��dvrtd��|std��tdd�|D��std��t|td�tf�s,td��|r4|r4td��t|td�tf�sAtd	��t|td�ttf�sOtd
��|r]|r]|��dkr]td��t|ttf�shtd
��|rvt	|�t	|�krvtd��||_
|p|d|_||_||_
|r�t|�nd|_||_t�j|d�dS)N>�gist�spgistz;Exclusion constraints only support GiST or SP-GiST indexes.zFAt least one expression is required to define an exclusion constraint.css*�|]}t|ttf�ot|�dkVqdS)�N)�
isinstance�list�tuple�len)�.0�exprrr�E/usr/lib/python3/dist-packages/django/contrib/postgres/constraints.py�	<genexpr>s
��
�z/ExclusionConstraint.__init__.<locals>.<genexpr>z+The expressions must be a list of 2-tuples.z3ExclusionConstraint.condition must be a Q instance.z7ExclusionConstraint with conditions cannot be deferred.z=ExclusionConstraint.deferrable must be a Deferrable instance.z4ExclusionConstraint.include must be a list or tuple.rz9Covering exclusion constraints only support GiST indexes.z6ExclusionConstraint.opclasses must be a list or tuple.zhExclusionConstraint.expressions and ExclusionConstraint.opclasses must have the same number of elements.�GISTr)�name)�lower�
ValueError�allr�typerrrrr�expressionsrr
rrr�super�__init__)�selfrr"rr
rrr��	__class__rrr$
s^����������
zExclusionConstraint.__init__c	s�g}t|j�D]K\}\}}t|t�rt|�}|j|d�}|�|�\}}	z|j|}
|
r1d||
f}Wn	ty;Ynw|t	�fdd�|	D��}|�
d||f�q|S)N)�queryz%s %sc3��|]}��|�VqdS�N��quote_value�r�p��
schema_editorrrrR��z:ExclusionConstraint._get_expression_sql.<locals>.<genexpr>z
%s WITH %s)�	enumerater"r�strr�resolve_expression�compiler�
IndexErrorr�append)r%�compilerr0r(r"�idx�
expression�operator�sql�params�opclassrr/r�_get_expression_sqlEs"

��z'ExclusionConstraint._get_expression_sqlcsF|jdurdS|�|j�}|�|�j�\}}|t�fdd�|D��S)Nc3r)r*r+r-r/rrr1z9ExclusionConstraint._get_condition_sql.<locals>.<genexpr>)r
�build_where�as_sql�
connectionr)r%r8r0r(�wherer<r=rr/r�_get_condition_sqlVs

z&ExclusionConstraint._get_condition_sqlc	s�t�dd�}|j|jd�}|�|||�}|�|||�}�fdd�|jD�}|j|�|j�|j	d�
|�|��|�|r=d|nd|�|j
�d	�S)
NF)�
alias_cols)rBcsg|]	}�j�|�j�qSr)�_meta�	get_field�column)r�
field_name��modelrr�
<listcomp>bsz6ExclusionConstraint.constraint_sql.<locals>.<listcomp>z, z WHERE (%s)�)rrr"rrCr)r	�get_compilerrBr?rDr�template�
quote_namerr�join�_index_include_sql�_deferrable_constraint_sqlr)r%rKr0r(r8r"r
rrrJr�constraint_sql]s


�z"ExclusionConstraint.constraint_sqlcCs,|�|�tdt|jj|j�|�||�d�S)Nz(ALTER TABLE %(table)s ADD %(constraint)s)�table�
constraint)�check_supportedrrrF�db_tablerPrT�r%rKr0rrr�
create_sqlls

�zExclusionConstraint.create_sqlcCs|�|j||�|j��Sr*)�_delete_constraint_sql�sql_delete_checkrPrrYrrr�
remove_sqlts

�zExclusionConstraint.remove_sqlcCs |jr|jjjstd��dSdS)Nz7Covering exclusion constraints requires PostgreSQL 12+.)rrB�features�supports_covering_gist_indexesr)r%r0rrrrW{s
��z#ExclusionConstraint.check_supportedcs�t���\}}}|j|d<|jdur|j|d<|j��dkr#|j|d<|jr+|j|d<|jr3|j|d<|jr;|j|d<|||fS)Nr"r
rrrrr)	r#�deconstructr"r
rrrrr)r%�path�args�kwargsr&rrr`�s







zExclusionConstraint.deconstructcslt||j�r0|j|jko/|j|jko/|j|jko/|j|jko/|j|jko/|j|jko/|j|jkSt	��
|�Sr*)rr'rrr"r
rrrr#�__eq__)r%�otherr&rrrd�s
�
�
�
�
�
�	zExclusionConstraint.__eq__c
Csrd|jj|j|j|jdurdnd|j|jdurdnd|j|js#dndt|j�|js0dfSdt|j�fS)Nz+<%s: index_type=%s, expressions=%s%s%s%s%s>rMz, condition=%sz, deferrable=%sz, include=%sz, opclasses=%s)	r'�__qualname__rr"r
rr�reprr)r%rrr�__repr__�s��zExclusionConstraint.__repr__)�__name__�
__module__rfrOr$r?rDrTrZr]rWr`rdrh�
__classcell__rrr&rr

s�8
N)�	django.dbr�!django.db.backends.ddl_referencesrr�django.db.modelsrrr�django.db.models.constraintsr�django.db.models.sqlr	�__all__r
rrrr�<module>s

https://t.me/RX1948 - 2025