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 :  /lib/python2.7/site-packages/south/db/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python2.7/site-packages/south/db/generic.pyc
�
xx�Rc@s�ddlmZddlZddlZddlmZddlmZmZddl	m
Z
ddlmZddl
mZddlmZdd	lmZdd
lmZddlmZyddlmZWn'ek
r�d
efd��YZnXddlmZddlmZmZd�Z d�Z!d�Z"d�Z#de$fd��YZ%de&fd��YZ'defd��YZ(d�Z)dS(i����(tprint_functionN(tno_style(ttransactiontmodels(t
DatabaseError(t
truncate_name(tBaseDatabaseCreation(tNOT_PROVIDED(t
dispatcher(tsettings(t
SortedDict(tcached_propertyRcBs eZdZd�Zd�ZRS(s�
        Decorator that creates converts a method with a single
        self argument into a property cached on the instance.
        cCs
||_dS(N(tfunc(tselfR((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt__init__scCs$|j|�}|j|jj<|S(N(Rt__dict__t__name__(R
tinstancettypetres((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt__get__s (Rt
__module__t__doc__RR(((s4/usr/lib/python2.7/site-packages/south/db/generic.pyRs	(t
get_logger(tstring_typest	text_typecs�fd�}|S(s�
    Returns a function which calls 'attrname' - for function aliasing.
    We can't just use foo = bar, as this breaks subclassing.
    cst|��||�S(N(tgetattr(R
targstkwds(tattrname(s4/usr/lib/python2.7/site-packages/south/db/generic.pyR's((RR((Rs4/usr/lib/python2.7/site-packages/south/db/generic.pytalias"scs�fd�}|S(Ncs&|j|dt��||||�S(Ntvalue(t
_set_cachetINVALID(R
ttableRtopts(R(s4/usr/lib/python2.7/site-packages/south/db/generic.pyt_cache_clear-s((RR$((Rs4/usr/lib/python2.7/site-packages/south/db/generic.pytinvalidate_table_constraints,scs�fd�}|S(Ncs,|j||dg��|||||�S(NR(R (R
R"tcolumnRR#(R(s4/usr/lib/python2.7/site-packages/south/db/generic.pyt
_column_rm4s((RR'((Rs4/usr/lib/python2.7/site-packages/south/db/generic.pytdelete_column_constraints3scs�fd�}|S(NcsM|jd�}|j||d|j|||���||||||�S(NtNAMER(t_get_settingR tlookup_constraint(R
R"t
column_oldt
column_newRR#tdb_name(R(s4/usr/lib/python2.7/site-packages/south/db/generic.pyt
_column_cp;s%((RR/((Rs4/usr/lib/python2.7/site-packages/south/db/generic.pytcopy_column_constraints:sR!cBseZd�ZRS(cCsdS(NR!((R
((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt__repr__Cs(RRR1(((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR!BstDryRunErrorcBseZRS((RR(((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR2GstDatabaseOperationscBs�eZdZdZdZdZdZdZdZdZ	dZ
dZd	Zd
Z
dZdZdZd
ZdYZdZeZeZeZeZeZed��Zd�ZdYd�ZdYed�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(d�Z)gd�Z*ged�Z+ddd �Z,d!�Z-d"�Z.d#�Z/dYd$�Z0d%�Z1e2d&��Z3e4d'�Z5e2d(��Z6e2ed)��Z7e4d*�Z8e2d+��Z9e2ed,��Z:d-�Z;d.�Z<d/�Z=d0�Z>e2ee?d1��Z@d2�ZAd3d4�ZBe2d5��ZCe2d6��ZDd7ee?d8�ZEd9�ZFd:�ZGd;�ZHe2d<��ZIe4d=�ZJdYd>�ZKd?�ZLd@�ZMd7dA�ZNe?d7dB�ZOe2e?d7dC��ZPe2d7dD��ZQe4dE�ZReSdF��ZTe4dG�ZUdH�ZVe2dI��ZWe4dJ�ZXe2dK��ZYdL�ZZdM�Z[dN�Z\dO�Z]dP�Z^dQ�Z_dRe?dS�Z`dRe?dT�Zad7dUebjcgidV�ZddW�ZedX�ZfRS(Zsr
    Generic SQL implementation of the DatabaseOperations.
    Some of this code comes from Django Evolution.
    s%ALTER COLUMN %(column)s TYPE %(type)ss%ALTER COLUMN %(column)s DROP NOT NULLs$ALTER COLUMN %(column)s SET NOT NULLs4ALTER TABLE %(table)s DROP CONSTRAINT %(constraint)ssALTER TABLE %s ADD COLUMN %s;s!ALTER TABLE %s DROP CONSTRAINT %ss$CREATE TABLE %(table)s (%(columns)s)i?sDROP INDEX %(index_name)ss&ALTER TABLE %s DROP COLUMN %s CASCADE;sMALTER TABLE %(table)s ADD CONSTRAINT %(constraint)s PRIMARY KEY (%(columns)s)s/ADD CONSTRAINT %(constraint)s CHECK (%(check)s)sALTER TABLE %s RENAME TO %s;tpubliccCs|j�|j�}t|jd�rE|jjrE|jj�ntf}y!ddlm}||f7}Wnt	k
r�nXt
|jdt�r|j�}|j
�|jd�|j�z.y|jd�Wn|k
r�tSXtSWd|jd�XntSdS(sp
        Tests the database using feature detection to see if it has
        transactional DDL support.
        tconfirmi����(tOperationalErrortsupports_transactionss)CREATE TABLE DDL_TRANSACTION_TEST (X INT)NsDROP TABLE DDL_TRANSACTION_TEST(t_possibly_initialiset_get_connectionthasattrtfeaturest
_confirmedR5RtMySQLdbR6tImportErrorRtTruetcursortstart_transactiontexecutetrollback_transactiontFalse(R
t
connectiont
exceptionsR6R@((s4/usr/lib/python2.7/site-packages/south/db/generic.pythas_ddl_transactionsjs.
	




cCsLt|_g|_t|_d|_g|_||_i|_t|_dS(Ni(	RDtdebugtdeferred_sqltdry_runtpending_transactionstpending_create_signalstdb_aliast_constraint_cachet_initialised(R
RM((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR�s							cs�����fd�}y|�}|SWnetk
rZ�j��=�j���n7tk
r��j���r}gS�j���nX�j����S(sB return a set() of constraints for db_name.table_name.column_name csN�j��}|tkr&t�n$�dkrBt|j��S|�SdS(N(RNR!tNonetlisttitems(R"(tcolumn_nameR.R
t
table_name(s4/usr/lib/python2.7/site-packages/south/db/generic.pyt_lookup�s	(R!RNt_fill_constraint_cachetKeyErrort_is_valid_cacheR+(R
R.RTRSRUtret((RSR.R
RTs4/usr/lib/python2.7/site-packages/south/db/generic.pyR+�s		

cCsf|jd�}y9|dk	r6||j|||<n||j||<Wnttfk
ranXdS(NR)(R*RPRNtLookupErrort	TypeError(R
RTRSRR.((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR �scCs2y|j||tk	SWntk
r-tSXdS(N(RNR!RWRD(R
R.RT((s4/usr/lib/python2.7/site-packages/south/db/generic.pyRX�s
cCs5yddlm}|Wntk
r,tSXtSdS(Ni����(tconnections(t	django.dbR\R>RDR?(R
R\((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt_is_multidb�s
cCs?|j�r'ddlm}||jSddlm}|SdS(sB
        Returns a django connection for a given DB Alias
        i����(R\(REN(R^R]R\RMRE(R
R\RE((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR9�s
cCsD|j�}|j�}|j�r/|j|Sttd|�SdS(sR
        Allows code to get a setting (like, for example, STORAGE_ENGINE)
        sDATABASE_%sN(tupperR9R^t
settings_dictRR	(R
tsetting_nameRE((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR*�s
cCs4y|j|�Wnttfk
r+tSXtSdS(s=
        Existence-checking version of _get_setting.
        N(R*RWtAttributeErrorRDR?(R
Ra((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt_has_setting�s
cCs3y|jd�SWnttfk
r.|jSXdS(Ntschema(R*RWRbtdefault_schema_name(R
((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt_get_schema_name�scCs#|js|j�t|_ndS(N(ROtconnection_initR?(R
((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR8�s	
cCsdS(s�
        Run before any SQL to let database-specific config be sent as a command,
        e.g. which storage engine (MySQL) or transaction serialisability level.
        N((R
((s4/usr/lib/python2.7/site-packages/south/db/generic.pyRg�scCs|j�jj|�S(sQ
        Uses the database backend to quote the given table/column name.
        (R9topst
quote_name(R
tname((s4/usr/lib/python2.7/site-packages/south/db/generic.pyRi�scCs2td|dtj�td|dtj�dS(Ns0FATAL ERROR - The following SQL query failed: %stfilesThe error was: %s(tprinttsyststderr(R
tetsqltparams((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt_print_sql_errorscCs�|j�|j�j�}|jr9td||�n|jrFgSt�jtd||f��y|j||�Wn2t	k
r�}|r�|j
|||�n�nXy|j�SWngSXdS(s�
        Executes the given SQL statement, with optional parameters.
        If the instance's debug attribute is True, prints out what it executes.
        s   = %ssexecute "%s" with params "%s"N(R8R9R@RHRlRJRRRBRRrtfetchall(R
RpRqtprint_all_errorsR@Ro((s4/usr/lib/python2.7/site-packages/south/db/generic.pyRBs"
		 s!(?mx) ([^';]* (?:'[^']*'[^';]*)*)s(?mx) (?:^\s*$)|(?:--.*$)cCs�djgtj||�D]*}|j�r|j�jdd�^q�}x8tj||�dddd�D]}|j|�qpWdS(s�
        Takes a SQL file and executes it as many separate statements.
        (Some backends, such as Postgres, don't work otherwise.)
        s
t%s%%iNi(tjointretsplittstriptreplaceRB(R
Rptregext
comment_regextxtst((s4/usr/lib/python2.7/site-packages/south/db/generic.pytexecute_many%sL*cCs|jj|�dS(s�
        Add a SQL statement to the deferred list, that won't be executed until
        this instance's execute_deferred_sql method is run.
        N(RItappend(R
Rp((s4/usr/lib/python2.7/site-packages/south/db/generic.pytadd_deferred_sql2scCs.x|jD]}|j|�q
Wg|_dS(sL
        Executes all deferred SQL, resetting the deferred_sql list
        N(RIRB(R
Rp((s4/usr/lib/python2.7/site-packages/south/db/generic.pytexecute_deferred_sql9scCs
g|_dS(s8
        Resets the deferred_sql list to empty.
        N(RI(R
((s4/usr/lib/python2.7/site-packages/south/db/generic.pytclear_deferred_sqlBscCs|j�|pg|_dS(s�
        Resets variables to how they should be before a run. Used for dry runs.
        If you want, pass in an old panding_creates to reset to.
        N(R�RL(R
tpending_creates((s4/usr/lib/python2.7/site-packages/south/db/generic.pytclear_run_dataHs
cCs|jS(N(RL(R
((s4/usr/lib/python2.7/site-packages/south/db/generic.pytget_pending_createsPscCs�t|�dkrtd�nx|D]\}}t|_q&Wg|D]!\}}|j|||�^qF}|j|ji|j|�d6djg|D]}|r�|^q��d6�dS(s�
        Creates the table 'table_name'. 'fields' is a tuple of fields,
        each repsented by a 2-part tuple of field name and a
        django.db.models.fields.Field object
        i?so   ! WARNING: You have a table name longer than 63 characters; this will not fully work on PostgreSQL or MySQL.R"s, tcolumnsN(	tlenRlR?t_suppress_defaultt
column_sqlRBtcreate_table_sqlRiRv(R
RTtfieldst
field_nametfieldR�tcol((s4/usr/lib/python2.7/site-packages/south/db/generic.pytcreate_tableSs

+R�cCsY||krdS|j|�|j|�f}|j|j|�|j|dt�dS(sE
        Renames the table 'old_table_name' to 'table_name'.
        NR(RiRBtrename_table_sqlR R!(R
told_table_nameRTRq((s4/usr/lib/python2.7/site-packages/south/db/generic.pytrename_tablens
cCsA|j|�f}|r,|jd|�n|jd|�dS(s1
        Deletes the table 'table_name'.
        sDROP TABLE %s CASCADE;sDROP TABLE %s;N(RiRB(R
RTtcascadeRq((s4/usr/lib/python2.7/site-packages/south/db/generic.pytdelete_table{sR�cCs'|j|�f}|jd|�dS(s5
        Deletes all rows from 'table_name'.
        sDELETE FROM %s;N(RiRB(R
RTRq((s4/usr/lib/python2.7/site-packages/south/db/generic.pytclear_table�scCs�|j|||�}|r�|j|�|f}|j|}|j|�|jdk	r�t|_|j|||dtdt	�q�ndS(sX
        Adds the column 'name' to the table 'table_name'.
        Uses the 'field' paramater, a django.db.models.fields.Field instance,
        to generate the necessary sql

        @param table_name: The name of the table to add the column to
        @param name: The name of the column to add
        @param field: The field to use
        t
explicit_nametignore_constraintsN(
R�Ritadd_column_stringRBtdefaultRPRtalter_columnRDR?(R
RTRjR�tkeep_defaultRpRq((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt
add_column�s	

	cCs9y|jd|j��SWntk
r4|j�SXdS(s�
        Returns a field's type suitable for ALTER COLUMN.
        By default it just returns field.db_type().
        To be overriden by backend specific subclasses
        @param field: The field to generate type for
        REN(tdb_typeR9R[(R
R�((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt_db_type_for_alter_column�s
cCsdS(s�
        Subcommand of alter_column that modifies column definitions beyond
        the type string -- e.g. adding constraints where they cannot be specified
        as part of the type (overrideable)
        N((R
R�RjRqtsqls((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt_alter_add_column_mods�scCs'|jd|j|�fgf�dS(sBSubcommand of alter_column that sets default values (overrideable)sALTER COLUMN %s DROP DEFAULTN(R�Ri(R
R�RjRqR�((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt_alter_set_defaults�scCs<|j|j�d|j��}|jd||g�dS(sMSubcommand of alter_column that updates nulls to default value (overrideable)REsAUPDATE %(table_name)s SET %(column)s=%%s WHERE %(column)s IS NULLN(tget_db_prep_savetget_defaultR9RB(R
RqR�R�((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt_update_nulls_to_default�s!c
Cs*|jr#|jrtd�ndSt|d�r?|j�n|j|�|s^|j}n	||_|s|jr�|j||gd�}xE|D]:}|j	|j
i|j|�d6|j|�d6�q�Wny|j||�Wqt
k
r�qXni|j|�d6|j|�d6|j|�d	6}g}	|ddk	rj|	j|j|gf�n|j||||	�|js�|j�r�|	j|j|gf�n|	j|j|gf�|j||||	�|jr2t|	�\}	}
|j	d
|j|�dj|	�ft|
��n:x7|	D]/\}}
|j	d
|j|�|f|
�q9W|jr�|j�r�|j||�|j	d
|j|�|j|fg�n|s&|jr&|jr&|j	|j||j|jj j!j"|jj j!j#|jj$�j��q&ndS(s�
        Alters the given column name so it will match the given field.
        Note that conversion between the two by the database must be possible.
        Will not automatically add _id by default; to have this behavour, pass
        explicit_name=False.

        @param table_name: The name of the table to add the column to
        @param name: The name of the column to alter
        @param field: The new field definition to use
        sC   - no dry run output for alter_column() due to dynamic DDL, sorryNt
south_inittCHECKR"t
constraintR&RRTsALTER TABLE %s %s;s, (%RJRHRlR:R�tset_attributes_from_nameR&thas_check_constraintst_constraints_affecting_columnsRBtdelete_check_sqlRitdelete_foreign_keyt
ValueErrorR�RPR�talter_string_set_typeR�tnullthas_defaulttalter_string_set_nulltalter_string_drop_nullR�tallows_combined_alterstzipRvtflattenR�treltsupports_foreign_keystforeign_key_sqlttot_metatdb_tablet	get_fieldR�(R
RTRjR�R�R�tcheck_constraintsR�RqR�tvaluesRp((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR��sf
		


		

	'-c
Cs�|j�}ddg}|jj|i�i|j||<x�|D]|}|jd|||g�}xW|D]O\}}}	|j||j|t��|j|||j|	|f�qlWqCWdS(Ntconstraint_column_usagetkey_column_usages�
                SELECT kc.constraint_name, kc.column_name, c.constraint_type
                FROM information_schema.%s AS kc
                JOIN information_schema.table_constraints AS c ON
                    kc.table_schema = c.table_schema AND
                    kc.table_name = c.table_name AND
                    kc.constraint_name = c.constraint_name
                WHERE
                    kc.table_schema = %%s AND
                    kc.table_name = %%s
            (RfRNt
setdefaultRBtsettadd(
R
R.RTRdtifsc_tablest
ifsc_tabletrowsR�R&tkind((s4/usr/lib/python2.7/site-packages/south/db/generic.pyRV/s

*tUNIQUEccs|jrtd��n|dk	r?ttd�|��}n|jd�}i}xp|j||�D]\\}}xM|D]E\}}	||krz|j|	t��||	j|j	��qzqzWqgWx:|j
�D],\}	}
|
|ks�|dkr�|	Vq�q�WdS(s�
        Gets the names of the constraints affecting the given columns.
        If columns is None, returns all constraints of the type on the table.
        s#Cannot get constraints for columns.cSs
|j�S(N(tlower(ts((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt<lambda>QsR)N(RJR2RPR�tmapR*R+R�R�R�RR(R
RTR�RR.tcnamesR�tconstraintsR�tcnametcols((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR�Hs	"cCs�t|ttf�s!|g}n|j||dd�}djt|j|��}|jd|j|�|j|�|f�|S(sP
        Creates a UNIQUE constraint on the columns on the given table.
        tsuffixt_uniqs, s,ALTER TABLE %s ADD CONSTRAINT %s UNIQUE (%s)(t
isinstanceRQttupletcreate_index_nameRvR�RiRB(R
RTR�RjR�((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt
create_unique`s	cCs�t|ttf�s!|g}n|jrD|jr@td�ndSt|j||��}|s{td||f��nx:|D]2}|j|j	|j
|�|j
|�f�q�WdS(sZ
        Deletes a UNIQUE constraint on precisely the columns on the given table.
        sK   - no dry run output for delete_unique_column() due to dynamic DDL, sorryNs7Cannot find a UNIQUE constraint on table %s, columns %r(R�RQR�RJRHRlR�R�RBtdelete_unique_sqlRi(R
RTR�R�R�((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt
delete_uniquess		

tc
Cs�|s|j|�nt|d�r2|j�n|j|�}y|jd|j��}Wntk
r||j�}nX|r|r�|j|j�|g}n	|g}|j	d|j
r�dp�d�|jr�|j	d�n|jr|j	d�n|j
p|}|rat|j�jdt�ra|jra|j	|j�jj|d	t��nd
j|�}d}	t|dt�s�|j�rP|j�}
|
dk	r�t|
�r�|
�}
n|j|
d|j��}
|j|
�}
t|
t�rd|
jd
d�}
nt|
t�r:|
jdd�}
n|d7}|
}	q�q�|j
rc|jsu|j�dkr�|jr�|j�jj r�|d7}q�q�n|j!r|j"r|j#|j$||j|j!j%j&j'|j!j%j&j(|j!j)�j��qnt|d�rCx-|j*t+�|�D]}|j#|�q)Wnt|j�j,d�r�|j-d|�}x9|j�j,j.||t+��D]}|j#|�q�Wn|r�||	SdSdS(sY
        Creates the SQL snippet for a column. Used by add_column and add_table.
        R�REs%sNULLsNOT R�sPRIMARY KEYR�tsupports_tablespacestinlinet R�s'%s't's''Rus%%s DEFAULT %ss DEFAULT ''tpost_create_sqltsql_indexes_for_fieldtFakeModelForGISCreationN((/R�R:R�t
_field_sanityR�R9R[RiR&R�R�tprimary_keytuniquet
db_tablespaceRR;RDRhttablespace_sqlR?RvR�R�RPtcallableR�t_default_value_workaroundR�RRztblanktempty_strings_allowedt!interprets_empty_strings_as_nullsR�R�R�R�R�R�R�R�R�R�Rtcreationt
mock_modelR�(
R
RTR�R�t
tablespacet	with_nametfield_preparedRptfield_outputt	sqlparamsR�tstmttmodel((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR��sr

	!		*(
%+(cCs|S(s�
        Placeholder for DBMS-specific field alterations (some combos aren't valid,
        e.g. DEFAULT and TEXT on MySQL)
        ((R
R�((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR��scCs+t|t�r#|jr#t|�S|SdS(s}
        DBMS-specific value alterations (this really works around
        missing functionality in Django backends)
        N(R�tboolthas_booleanstint(R
R((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR��s
cCs~d|||j||�f}d|j|�|j|j|��|j|�|j|�|j|�|j�jj�fS(sP
        Generates a full SQL statement to add a foreign key constraint
        s
%s_refs_%s_%ssGALTER TABLE %s ADD CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)%s;(t_digestRitshorten_nameR9Rhtdeferrable_sql(R
tfrom_table_nametfrom_column_namet
to_table_nametto_column_nametconstraint_name((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR�scCs�|jr#|jrtd�ndS|j||�}|sTtd||f��nxB|D]:}|j|ji|j|�d6|j|�d6�q[WdS(s/
        Drop a foreign key constraint
        sI   - no dry run output for delete_foreign_key() due to dynamic DDL, sorryNs;Cannot find a FOREIGN KEY constraint on table %s, column %sR"R�(RJRHRlt_find_foreign_constraintsR�RBtdelete_foreign_key_sqlRi(R
RTR&R�R�((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR�s		

R�cCs�|j||gd�}|j|�}t|�dkrCt|�S|j|�t|j||d��}t|j|��SdS(NsFOREIGN KEYi(R�t_find_primary_key_columnsR�RQR�R�tunion(R
RTRSR�tprimary_key_columnstrecursive_constraints((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR#s

	cGs7t|d�s't|j��|_n|jj|�S(s�
        Use django.db.backends.creation.BaseDatabaseCreation._digest
        to create index name in Django style. An evil hack :(
        t_django_db_creation(R:RR9RR�(R
R((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR�2scCst||j�jj��S(N(RR9Rhtmax_name_length(R
Rj((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR�;scCs:t|�dkrq|rqy|j|dg�}Wn$tk
rY|j|d�}nX|jd||f�S|jdd�jdd�}dtt|d	j|�f��}d
||d||fjdd�jdd�}t|�|jkr6d|d||f}d||jt|� |f}n|S(
s6
        Generate a unique name for the index
        iis%s_%st"R�t.t_s_%xt,s	%s_%s%s%ss_%s%s%ss%s%s(	R�R�R[R�RztabsthashRvtmax_index_name_length(R
RTtcolumn_namesR�t_hashtindex_unique_namet
index_nametpart((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR�>s
%2$c	Cs�|std�dS|j�}|rK|jjrKd|jj|�}nd}|j||�}d|rrdpud|j|�|j|�djg|D]}|j|�^q��|fS(sa
        Generates a create index statement on 'table_name' for a list of 'column_names'
        s4No column names supplied on which to create an indexR�R�sCREATE %sINDEX %s ON %s (%s)%s;sUNIQUE R(	RlR9R;R�RhR�R�RiRv(	R
RTRR�R�RER�RR�((s4/usr/lib/python2.7/site-packages/south/db/generic.pytcreate_index_sqlZs
(cCs)|j||||�}|j|�dS(s# Executes a create index statement N(RRB(R
RTRR�R�Rp((s4/usr/lib/python2.7/site-packages/south/db/generic.pytcreate_indexqscCskt|t�r|g}n|j||�}|ji|j|�d6|j|�d6}|j|�dS(s�
        Deletes an index created with create_index.
        This is possible using only columns due to the deterministic
        index naming function which relies on column names.
        RRTN(R�RR�tdrop_index_stringRiRB(R
RTRR�RjRp((s4/usr/lib/python2.7/site-packages/south/db/generic.pytdelete_indexws	RcCs9|j|�|j|�f}|j|j|g�dS(sO
        Deletes the column 'column_name' from the table 'table_name'.
        N(RiRBtdelete_column_string(R
RTRjRq((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt
delete_column�sRcCstd��dS(sP
        Renames the column 'old' from the table 'table_name' to 'new'.
        s'rename_column has no generic SQL syntaxN(tNotImplementedError(R
RTtoldtnew((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt
rename_column�scCs�|jr#|jrtd�ndSt|j|ddd��}|s]td|f��nxB|D]:}|j|ji|j	|�d6|j	|�d6�qdWdS(s,
        Drops the old primary key.
        sI   - no dry run output for delete_primary_key() due to dynamic DDL, sorryNRsPRIMARY KEYs0Cannot find a PRIMARY KEY constraint on table %sR"R�(
RJRHRlRQR�RPR�RBtdelete_primary_key_sqlRi(R
RTR�R�((s4/usr/lib/python2.7/site-packages/south/db/generic.pytdelete_primary_key�s		

RcCsyt|ttf�s!|g}n|j|ji|j|�d6|j|d�d6djt|j|��d6�dS(sE
        Creates a new primary key on the specified columns.
        R"t_pkeyR�s, R�N(R�RQR�RBtcreate_primary_key_stringRiRvR�(R
RTR�((s4/usr/lib/python2.7/site-packages/south/db/generic.pytcreate_primary_key�scCsx|jd�}t�}xY|j||�D]E\}}x6|D].\}}|dkr>|j|j��q>q>Wq+W|S(sL
        Find all columns of the primary key of the specified table
        R)sPRIMARY KEY(R*R�R+R�R�(R
RTR.RR�R�R�R�((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR�s	cCs[|jr|jd7_ntjd|j�tjd|j�tjtd|j�dS(s�
        Makes sure the following commands are inside a transaction.
        Must be followed by a (commit|rollback)_transaction call.
        itusingN(RJRKRtcommit_unless_managedRMtenter_transaction_managementtmanagedR?(R
((s4/usr/lib/python2.7/site-packages/south/db/generic.pyRA�s
	cCs7|jr
dStjd|j�tjd|j�dS(sh
        Commits the current transaction.
        Must be preceded by a start_transaction call.
        NR#(RJRtcommitRMtleave_transaction_management(R
((s4/usr/lib/python2.7/site-packages/south/db/generic.pytcommit_transaction�s	cCsE|jr|jd8_ntjd|j�tjd|j�dS(sk
        Rolls back the current transaction.
        Must be preceded by a start_transaction call.
        iR#N(RJRKRtrollbackRMR((R
((s4/usr/lib/python2.7/site-packages/south/db/generic.pyRC�s	cCs\|js
dSx|jdkr,|j�qWtjd|j�rXtjd|j�ndS(sJ
        Rolls back all pending_transactions during this dry run.
        NiR#(RJRKRCRtis_dirtyRMR((R
((s4/usr/lib/python2.7/site-packages/south/db/generic.pytrollback_transactions_dry_run�s	cCs|jj||f�dS(N(RLR�(R
t	app_labeltmodel_names((s4/usr/lib/python2.7/site-packages/south/db/generic.pytsend_create_signal�sicCs�t�}xP|jD]E\}}y||j|�Wqtk
rWt|�||<qXqWxB|j�D]4\}}|j|tt|��d|d|�qiWg|_dS(Nt	verbositytinteractive(R
RLtextendRWRQRRtreally_send_create_signalR�(R
R0R1tsignalsR-R.((s4/usr/lib/python2.7/site-packages/south/db/generic.pytsend_pending_create_signals�s	
c	
Cs?|jr td||f�ntj|�}|s9dSg}x6|D].}tj||�}|rF|j|�qFqFW|r;ttd�r�tjdtj	j
d|d|d|d|d	|�q;|j�r
tj	j
jd|d|d|d|d	|d
|j�q;tj	j
jd|d|d|d|d	|�ndS(s�
        Sends a post_syncdb signal for the model specified.

        If the model is not found (perhaps it's been deleted?),
        no signal is sent.

        TODO: The behavior of django.contrib.* apps seems flawed in that
        they don't respect created_models.  Rather, they blindly execute
        over all models within the app sending the signal.  This is a
        patch we should push Django to make  For now, this should work.
        s( - Sending post_syncdb signal for %s: %sNtsendtsignaltsendertapptcreated_modelsR0R1tdb(
RHRlRtget_appt	get_modelR�R:RR6R4tpost_syncdbR^RM(	R
R-R.R0R1R9R:t
model_nameR�((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR3	s:	

tidc
	s`dtf�������fd��Y}dtfd��Y}	|�|	_|	|	j_|	S(sT
        Generates a MockModel class that provides enough information
        to be used by a foreign key/many-to-many relationship.

        Migrations should prefer to use these rather than actual models
        as models could get deleted over time, but these can remain in
        migration files forever.

        Depreciated.
        tMockOptionscs;eZ�������fd�Zd�Zd�ZRS(cs~�|_�ptj|_�|_�j�|_�tjkrOt	�d<n����|_
|j
j��t|_
dS(NR�(R�R	tDEFAULT_TABLESPACER�tobject_nameR�tmodule_nameRt	AutoFieldR?tpkR�RDtabstract(R
(R�R�R?t
pk_field_argstpk_field_kwargst
pk_field_namet
pk_field_type(s4/usr/lib/python2.7/site-packages/south/db/generic.pyRNs		
cSs|j|jttfS(N(RFR�R?RD(R
R�((s4/usr/lib/python2.7/site-packages/south/db/generic.pytget_field_by_name[scSs|jS(N(RF(R
Rj((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR�_s(RRRRLR�((R�R�R?RHRIRJRK(s4/usr/lib/python2.7/site-packages/south/db/generic.pyRAMs!
	t	MockModelcBseZdZRS(N(RRRPR�(((s4/usr/lib/python2.7/site-packages/south/db/generic.pyRMcs(tobjectR�R�(
R
R?R�R�RJRKRHRIRARM((R�R�R?RHRIRJRKs4/usr/lib/python2.7/site-packages/south/db/generic.pyR�@s

.cCsKt||�j|�}t|tjtjf�rG|jdd�dS|S(s`
        A helper for subclasses overriding _db_type_for_alter_column:
        Remove the check constraint from the type string for PositiveInteger
        and PositiveSmallInteger fields.
        @param klass: The type of the child (required to allow this to be used when it is subclassed)
        @param field: The field to generate type for
        R�ii(tsuperR�R�RtPositiveSmallIntegerFieldtPositiveIntegerFieldRx(R
tklassR�tsuper_result((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt"_db_positive_type_for_alter_columnkscCs�t||�j||||�t|tjtjf�r�ttt|j	����}t
dd|t|�dfdd|j|��}|j
|j|gf�ndS(s�
        A helper for subclasses overriding _alter_add_column_mods:
        Add a check constraint verifying positivity to PositiveInteger and
        PositiveSmallInteger fields.
        R�s
CK_%s_PSTV_%sitchecks%s >= 0N(ROR�R�RRPRQRR
R�R�tdictthexRiR�tadd_check_constraint_fragment(R
RRR�RjRqR�t	uniq_hashtd((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt_alter_add_positive_checkxsN(gRRRR�R�R�R�R�R�RR�RRRR!RRXR�RPtbackend_nameReR?R�R�R�R�traises_default_errorsRRGRR+R!R RXR^R9R*RcRfR8RgRiRrRBRR�R�R�R�R�R%R�Rt	add_tableR�R�t
drop_tableR�R�R�R�R�R�RDR�RVR�R�R�R�R�R�R�R�tdrop_foreign_keyRR�R�R�RRRt
drop_indexR(Rtdrop_columnRRtdrop_primary_keyR"RRAR)RCR,R/R5R3RRER�RTR[(((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR3Ks�#	

					
					
					

				d	e		
					
			
	
	
	6	)	
cCs%g}x|D]}||7}q
W|S(N((tlstnltl((s4/usr/lib/python2.7/site-packages/south/db/generic.pyR��s
(*t
__future__RRwRmtdjango.core.management.colorRR]RRtdjango.db.utilsRtdjango.db.backends.utilRtdjango.db.backends.creationRtdjango.db.models.fieldsRtdjango.dispatchRtdjango.confR	tdjango.utils.datastructuresR
tdjango.utils.functionalRR>RNtsouth.loggerRtsouth.utils.py3RRRR%R(R0t	ExceptionR!R�R2R3R�(((s4/usr/lib/python2.7/site-packages/south/db/generic.pyt<module>s:
	
			����A

https://t.me/AnonymousX5 - 2025