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/backends/oracle/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/db/backends/oracle/__pycache__/schema.cpython-310.pyc
o

3�a�#�@sDddlZddlZddlZddlmZddlmZGdd�de�ZdS)�N)�
DatabaseError)�BaseDatabaseSchemaEditorcs�eZdZdZdZdZdZdZdZeZ	dZ
dZd	Zd
Z
dZdd
�Z�fdd�Z�fdd�Zd+�fdd�	Z�fdd�Z�fdd�Zdd�Zdd�Zdd�Z�fdd �Z�fd!d"�Zd#d$�Zd%d&�Zd'd(�Z�fd)d*�Z�ZS),�DatabaseSchemaEditorz3ALTER TABLE %(table)s ADD %(column)s %(definition)szMODIFY %(column)s %(type)szMODIFY %(column)s NULLzMODIFY %(column)s NOT NULLz%MODIFY %(column)s DEFAULT %(default)szMODIFY %(column)s DEFAULT NULLz'MODIFY %(column)s %(type)s%(collation)sz,ALTER TABLE %(table)s DROP COLUMN %(column)szHCONSTRAINT %(name)s REFERENCES %(to_table)s(%(to_column)s)%(deferrable)sz(DROP TABLE %(table)s CASCADE CONSTRAINTSz9CREATE INDEX %(name)s ON %(table)s (%(columns)s)%(extra)scCszt|tjtjtjf�rd|St|t�r d|�dd��dd�St|tttf�r.d|�	�St|t
�r9|r7dSdSt|�S)Nz'%s'�'z''�%z%%�1�0)�
isinstance�datetime�date�time�str�replace�bytes�	bytearray�
memoryview�hex�bool��self�value�r�B/usr/lib/python3/dist-packages/django/db/backends/oracle/schema.py�quote_values

z DatabaseSchemaEditor.quote_valuecs6|�|jj|j�r|�|jj|j�t��||�dS�N)�_is_identity_column�_meta�db_table�column�_drop_identity�super�remove_field)r�model�field��	__class__rrr!%sz!DatabaseSchemaEditor.remove_fieldcs0t��|�|�dd|jj�|jj�i�dS)NaK
            DECLARE
                i INTEGER;
            BEGIN
                SELECT COUNT(1) INTO i FROM USER_SEQUENCES
                    WHERE SEQUENCE_NAME = '%(sq_name)s';
                IF i = 1 THEN
                    EXECUTE IMMEDIATE 'DROP SEQUENCE "%(sq_name)s"';
                END IF;
            END;
        /�sq_name)r �delete_model�execute�
connection�ops�_get_no_autofield_sequence_namerr)rr"r$rrr',s

�z!DatabaseSchemaEditor.delete_modelFc
s�zt��||||�WdStyn}zVt|�}d|vs d|vr(|�|||�n-d|vr>|�|jj|j�|�||||�nd|vrT|j	rT|j
|dd�|�|||�n�WYd}~dSWYd}~dSWYd}~dSd}~ww)Nz	ORA-22858z	ORA-22859z	ORA-30675z	ORA-30673T)�strict)r �alter_fieldrr
�_alter_field_type_workaroundrrrr�primary_key�_delete_primary_key)rr"�	old_field�	new_fieldr,�e�descriptionr$rrr-<s$���z DatabaseSchemaEditor.alter_fieldcs�t�|�}|��dv|_|�|j�|_|�||�|�|j�}|�|j	�}t
�d|�r1d|}d}t
�d|�rU|��}|dkrDd|}n|dkrMd	|}n|d
krUd|}|�d|�|j
j�|�|j�|f�|�||�t��|||�d
S)a�
        Oracle refuses to change from some type to other type.
        What we need to do instead is:
        - Add a nullable version of the desired field with a temporary name. If
          the new column is an auto field, then the temporary column can't be
          nullable.
        - Update the table to transfer values from old to new
        - Drop old column
        - Rename the new column and possibly drop the nullable property
        )�	AutoField�BigAutoField�SmallAutoFieldz^N?CLOBzTO_CHAR(%s)�VARCHAR2z^N?VARCHAR2�	DateFieldzTO_DATE(%s, 'YYYY-MM-DD')�
DateTimeFieldz,TO_TIMESTAMP(%s, 'YYYY-MM-DD HH24:MI:SS.FF')�	TimeFieldzCTO_TIMESTAMP(CONCAT('1900-01-01 ', %s), 'YYYY-MM-DD HH24:MI:SS.FF')zUPDATE %s set %s=%sN)�copy�deepcopy�get_internal_type�null�_generate_temp_namer�	add_field�
quote_name�db_typer)�re�matchr(rrr!r r-)rr"r1r2�new_temp_field�	new_value�old_type�new_internal_typer$rrr.Rs0




�z1DatabaseSchemaEditor._alter_field_type_workaroundcsVhd�}|��|vr"|��|vr"|�|jj|j�r"|�|jj|j�t��||||�S)N>r5r6r7)r>rrrrrr �_alter_column_type_sql)rr"r1r2�new_type�auto_field_typesr$rrrJ�s�z+DatabaseSchemaEditor._alter_column_type_sqlcCs2|�|�}|ddkr|ddkr|dd�}|S)z�
        Get the properly shortened and uppercased identifier as returned by
        quote_name() but without the quotes.
        r�"����)rB)r�name�nnrrr�normalize_name�s
z#DatabaseSchemaEditor.normalize_namecCs*tt|����dd�}|�|d|�S)z@Generate temporary names for workarounds that need temp columns.rON�_)r�hash�upperrR)r�for_name�suffixrrrr@�sz(DatabaseSchemaEditor._generate_temp_namecCs
|�|�Sr)rrrrr�prepare_default�s
z$DatabaseSchemaEditor.prepare_defaultcs:t��||�}|�|j�}|dur|��|jjvrdS|S)NF)r �_field_should_be_indexedrCr)�lower�_limited_data_types)rr"r#�create_indexrCr$rrrY�s
z-DatabaseSchemaEditor._field_should_be_indexedcst��||�o
|�||�Sr)r �_unique_should_be_added�_field_became_primary_key)rr1r2r$rrr]�s�z,DatabaseSchemaEditor._unique_should_be_addedcCsb|j���"}|�d|�|�|�|�g�|��}|r|dndWd�S1s*wYdS)Nz�
                SELECT
                    CASE WHEN identity_column = 'YES' THEN 1 ELSE 0 END
                FROM user_tab_cols
                WHERE table_name = %s AND
                      column_name = %s
            rF�r)�cursorr(rR�fetchone)r�
table_name�column_namer`�rowrrrr�s�$�z(DatabaseSchemaEditor._is_identity_columncCs$|�d|�|�|�|�d��dS)Nz5ALTER TABLE %(table)s MODIFY %(column)s DROP IDENTITY)�tabler)r(rB)rrbrcrrrr�s�z#DatabaseSchemaEditor._drop_identitycCsN|j���}|�d|�|�g�|��dWd�S1s wYdS)Nz]
                SELECT default_collation FROM user_tables WHERE table_name = %s
            rr_)rrbr`rrr�_get_default_collation�s
�
$�z+DatabaseSchemaEditor._get_default_collationcs(|dur|�|jj�}t��||||�Sr)rfrrr �_alter_column_collation_sql)rr"r2rK�
new_collationr$rrrg�sz0DatabaseSchemaEditor._alter_column_collation_sql)F)�__name__�
__module__�__qualname__�sql_create_column�sql_alter_column_type�sql_alter_column_null�sql_alter_column_not_null�sql_alter_column_default�sql_alter_column_no_default� sql_alter_column_no_default_null�sql_alter_column_collate�sql_delete_column�sql_create_column_inline_fk�sql_delete_table�sql_create_indexrr!r'r-r.rJrRr@rXrYr]rrrfrg�
__classcell__rrr$rr	s8.
r)r<r
rD�	django.dbr�django.db.backends.base.schemarrrrrr�<module>s

https://t.me/RX1948 - 2025