
    gv                         d dl Z d dlZd dlZd dlZd dlmZ d dlZd dlmZ d dl	m
Z
mZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ  G d
 d      Zy)    N)import_module)settings)NotSupportedErrortransaction)utilsCol)timezone)RemovedInDjango60Warning	force_strc            
       X   e Zd ZdZdZdddddddddd		Zd
dddZi ZdZdZ	dZ
de	z   Zde
z   ZdZdZd Zd Zd Zd Zd Zd Zd ZdbdZd Zd Zd Zd ZdbdZd  Zd! Zd" Zd# Zd$ Z d% Z!d& Z"dcd(Z#d) Z$d* Z%d+ Z&d, Z'd- Z(dbd.Z)d/ Z*d0 Z+d1 Z,d2 Z-d3 Z.d4 Z/d5 Z0d6 Z1d7 Z2d8 Z3d9 Z4d: Z5d; Z6d< Z7d'd'd=d>Z8d? Z9d@ Z:dA Z;dB Z<dddCZ=dedDZ>dE Z?e?Z@dF ZAdG ZBdH ZCdI ZDdJ ZEdK ZFdfdLZGdM ZHdN ZIdedOZJdedPZKdQ ZLdR ZMdS ZNdT ZOdU ZPdV ZQdW ZRdX ZSdY ZTdZ ZUd[ ZVdfd\ZWdfd]ZXdbd^ZYdbd_ZZd` Z[da Z\y)gBaseDatabaseOperationsz
    Encapsulate backend-specific differences, such as the way a backend
    performs ordering or calculates the ID of a recently-inserted row.
    zdjango.db.models.sql.compiler)i   )i   )l             )r   r   )r   r   )r   r   )	SmallIntegerFieldIntegerFieldBigIntegerFieldPositiveBigIntegerFieldPositiveSmallIntegerFieldPositiveIntegerFieldSmallAutoField	AutoFieldBigAutoFieldUNION	INTERSECTEXCEPT)unionintersection
differenceN	PRECEDING	FOLLOWINGz
UNBOUNDED zCURRENT ROWc                      || _         d | _        y N)
connection_cache)selfr&   s     z/var/www/python.vincentserveurtest.ovh/public_html/venv/lib/python3.12/site-packages/django/db/backends/base/operations.py__init__zBaseDatabaseOperations.__init__=   s    $    c                      y)z
        Return any SQL needed to support auto-incrementing primary keys, or
        None if no SQL is necessary.

        This SQL is executed when a table is created.
        N )r(   tablecolumns      r)   autoinc_sqlz"BaseDatabaseOperations.autoinc_sqlA   s     r+   c                     t        |      S )z
        Return the maximum allowed batch size for the backend. The fields
        are the fields going to be inserted in the batch, the objs contains
        all the objects to be inserted.
        )len)r(   fieldsobjss      r)   bulk_batch_sizez&BaseDatabaseOperations.bulk_batch_sizeJ   s     4yr+   c                     t        d      )Nz[subclasses of BaseDatabaseOperations may require a format_for_duration_arithmetic() method.NotImplementedError)r(   sqls     r)   format_for_duration_arithmeticz5BaseDatabaseOperations.format_for_duration_arithmeticR   s    !7
 	
r+   c                 6    | j                  d      }d| d| dS )z
        Return an SQL query that retrieves the first cache key greater than the
        n smallest.

        This is used by the 'db' cache backend to determine where to start
        culling.
        	cache_keyzSELECT z FROM %s ORDER BY z LIMIT 1 OFFSET %%s
quote_name)r(   r<   s     r)   cache_key_culling_sqlz,BaseDatabaseOperations.cache_key_culling_sqlX   s)     OOK0	#5i[@STTr+   c                      y)z
        Given a field instance, return the SQL that casts the result of a union
        to that type. The resulting string should contain a '%s' placeholder
        for the expression being cast.
        %sr-   )r(   output_fields     r)   unification_cast_sqlz+BaseDatabaseOperations.unification_cast_sqlc        r+   c                     t        d      )z
        Given a lookup_type of 'year', 'month', or 'day', return the SQL that
        extracts a value from the given date field field_name.
        zLsubclasses of BaseDatabaseOperations may require a date_extract_sql() methodr7   r(   lookup_typer9   paramss       r)   date_extract_sqlz'BaseDatabaseOperations.date_extract_sqlk   s    
 "
 	
r+   c                     t        d      )a.  
        Given a lookup_type of 'year', 'month', or 'day', return the SQL that
        truncates the given date or datetime field field_name to a date object
        with only the given specificity.

        If `tzname` is provided, the given value is truncated in a specific
        timezone.
        zKsubclasses of BaseDatabaseOperations may require a date_trunc_sql() method.r7   r(   rG   r9   rH   tznames        r)   date_trunc_sqlz%BaseDatabaseOperations.date_trunc_sqlu   s     "
 	
r+   c                     t        d      )zH
        Return the SQL to cast a datetime value to date value.
        zSsubclasses of BaseDatabaseOperations may require a datetime_cast_date_sql() method.r7   r(   r9   rH   rL   s       r)   datetime_cast_date_sqlz-BaseDatabaseOperations.datetime_cast_date_sql   s     "/
 	
r+   c                     t        d      )zH
        Return the SQL to cast a datetime value to time value.
        zRsubclasses of BaseDatabaseOperations may require a datetime_cast_time_sql() methodr7   rO   s       r)   datetime_cast_time_sqlz-BaseDatabaseOperations.datetime_cast_time_sql   s     ".
 	
r+   c                     t        d      )z
        Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute', or
        'second', return the SQL that extracts a value from the given
        datetime field field_name.
        zPsubclasses of BaseDatabaseOperations may require a datetime_extract_sql() methodr7   rK   s        r)   datetime_extract_sqlz+BaseDatabaseOperations.datetime_extract_sql        "
 	
r+   c                     t        d      )z
        Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute', or
        'second', return the SQL that truncates the given datetime field
        field_name to a datetime object with only the given specificity.
        zNsubclasses of BaseDatabaseOperations may require a datetime_trunc_sql() methodr7   rK   s        r)   datetime_trunc_sqlz)BaseDatabaseOperations.datetime_trunc_sql   rU   r+   c                     t        d      )a1  
        Given a lookup_type of 'hour', 'minute' or 'second', return the SQL
        that truncates the given time or datetime field field_name to a time
        object with only the given specificity.

        If `tzname` is provided, the given value is truncated in a specific
        timezone.
        zJsubclasses of BaseDatabaseOperations may require a time_trunc_sql() methodr7   rK   s        r)   time_trunc_sqlz%BaseDatabaseOperations.time_trunc_sql   s     "X
 	
r+   c                 (    | j                  |||      S )z
        Given a lookup_type of 'hour', 'minute', or 'second', return the SQL
        that extracts a value from the given time field field_name.
        )rI   rF   s       r)   time_extract_sqlz'BaseDatabaseOperations.time_extract_sql   s    
 $$[#v>>r+   c                      y)zs
        Return the SQL to make a constraint "initially deferred" during a
        CREATE TABLE statement.
         r-   r(   s    r)   deferrable_sqlz%BaseDatabaseOperations.deferrable_sql   s    
 r+   c                 &    |rt        d      dgg fS )z
        Return an SQL DISTINCT clause which removes duplicate rows from the
        result set. If any fields are given, only check the given fields for
        duplicates.
        z<DISTINCT ON fields is not supported by this database backendDISTINCT)r   )r(   r3   rH   s      r)   distinct_sqlz#BaseDatabaseOperations.distinct_sql   s&     #N  <##r+   c                 "    |j                         S )z
        Given a cursor object that has just performed an INSERT...RETURNING
        statement into a table, return the newly created data.
        )fetchone)r(   cursorreturning_paramss      r)   fetch_returned_insert_columnsz4BaseDatabaseOperations.fetch_returned_insert_columns   s    
   r+   c                 8    t        j                  dt               y)a)  
        Given a column type (e.g. 'BLOB', 'VARCHAR') and an internal type
        (e.g. 'GenericIPAddressField'), return the SQL to cast it before using
        it in a WHERE statement. The resulting string should contain a '%s'
        placeholder for the column being searched against.
        z_DatabaseOperations.field_cast_sql() is deprecated use DatabaseOperations.lookup_cast() instead.rA   )warningswarnr   )r(   db_typeinternal_types      r)   field_cast_sqlz%BaseDatabaseOperations.field_cast_sql   s     	< %	
 r+   c                     g S )zm
        Return a GROUP BY clause to use with a HAVING clause when no grouping
        is specified.
        r-   r^   s    r)   force_group_byz%BaseDatabaseOperations.force_group_by   	    
 	r+   c                     g S )z
        Return a list used in the "ORDER BY" clause to force no ordering at
        all. Return an empty list to include nothing in the ordering.
        r-   r^   s    r)   force_no_orderingz(BaseDatabaseOperations.force_no_ordering   rp   r+   Fc                 b    d|rdndd|rddj                  |      z  nd|rdnd|rdS dS )	zX
        Return the FOR UPDATE SQL clause to lock rows for an update operation.
        FORz NO KEYr]   z UPDATEz OF %s, z NOWAITz SKIP LOCKEDjoin)r(   nowaitskip_lockedofno_keys        r)   for_update_sqlz%BaseDatabaseOperations.for_update_sql   sS    
  IR'(*Htyy}$2IR')N1	
 	
 021	
 	
r+   c                 x    |xs d}|||z
  |fS |r&| j                   j                  j                         |fS d |fS Nr   )r&   opsno_limit_value)r(   low_mark	high_markoffsets       r)   _get_limit_offset_paramsz/BaseDatabaseOperations._get_limit_offset_params  sL    Q &//??&&557??V|r+   c                 |    | j                  ||      \  }}dj                  d |rd|z  nd|rd|z  ndfD              S )zReturn LIMIT/OFFSET SQL clause. c              3   $   K   | ]  }|r| 
 y wr%   r-   ).0r9   s     r)   	<genexpr>z:BaseDatabaseOperations.limit_offset_sql.<locals>.<genexpr>  s!      
  s   zLIMIT %dNz	OFFSET %d)r   rw   )r(   r   r   limitr   s        r)   limit_offset_sqlz'BaseDatabaseOperations.limit_offset_sql  sR    55h	Jvxx 
 ).e#4*0v%d
 
 	
r+   c                 n    d |D        }dj                  |D cg c]  }d| d
 c}      }d| S c c}w )Nc              3   >   K   | ]  }d j                  |        yw)ru   Nrv   )r   rows     r)   r   z9BaseDatabaseOperations.bulk_insert_sql.<locals>.<genexpr>  s     K:J3		#:Js   ru   ()zVALUES rv   )r(   r3   placeholder_rowsplaceholder_rows_sqlr9   
values_sqls         r)   bulk_insert_sqlz&BaseDatabaseOperations.bulk_insert_sql  sI    K:JKYY6JK6Js!C5
6JKL
%%  Ls   2c                     d t        |t        t        f      rt        fd|D              }n4|d}n/|j                         D ci c]  \  }} |       |       }}}d|d|S c c}}w )a  
        Return a string of the query last executed by the given cursor, with
        placeholders replaced with actual values.

        `sql` is the raw query containing placeholders and `params` is the
        sequence of parameters. These are used by default, but this method
        exists for database backends to provide a better implementation
        according to their own quoting schemes.
        c                     t        | dd      S )NTreplace)strings_onlyerrorsr   )ss    r)   	to_stringz=BaseDatabaseOperations.last_executed_query.<locals>.to_string(  s    QT)DDr+   c              3   .   K   | ]  } |        y wr%   r-   )r   valr   s     r)   r   z=BaseDatabaseOperations.last_executed_query.<locals>.<genexpr>,  s     >vYs^vs   r-   zQUERY = z - PARAMS = )
isinstancelisttupleitems)r(   re   r9   rH   u_paramskvr   s          @r)   last_executed_queryz*BaseDatabaseOperations.last_executed_query  sp    	E ftUm,>v>>H^H?E||~N~tq!	!il2~HN-0(;; Os   A,c                     |j                   S )z
        Given a cursor object that has just performed an INSERT statement into
        a table that has an auto-incrementing ID, return the newly created ID.

        `pk_name` is the name of the primary-key column.
        )	lastrowid)r(   re   
table_namepk_names       r)   last_insert_idz%BaseDatabaseOperations.last_insert_id4  s     r+   c                      y)z
        Return the string to use in a query when performing lookups
        ("contains", "like", etc.). It should contain a '%s' placeholder for
        the column being searched against.
        rA   r-   )r(   rG   rl   s      r)   lookup_castz"BaseDatabaseOperations.lookup_cast=  rD   r+   c                      y)z
        Return the maximum number of items that can be passed in a single 'IN'
        list condition, or None if the backend does not impose a limit.
        Nr-   r^   s    r)   max_in_list_sizez'BaseDatabaseOperations.max_in_list_sizeE      
 r+   c                      y)zl
        Return the maximum length of table and column names, or None if there
        is no limit.
        Nr-   r^   s    r)   max_name_lengthz&BaseDatabaseOperations.max_name_lengthL  r   r+   c                     t        d      )z
        Return the value to use for the LIMIT when we are wanting "LIMIT
        infinity". Return None if the limit clause can be omitted in this case.
        zJsubclasses of BaseDatabaseOperations may require a no_limit_value() methodr7   r^   s    r)   r   z%BaseDatabaseOperations.no_limit_valueS  s    
 "X
 	
r+   c                      y)z
        Return the value to use during an INSERT statement to specify that
        the field should use its default value.
        DEFAULTr-   r^   s    r)   pk_default_valuez'BaseDatabaseOperations.pk_default_value\  s    
 r+   c                     t        j                  |      D cg c]  }|rt        j                  |d       c}S c c}w )ag  
        Take an SQL script that may contain multiple lines and return a list
        of statements to feed to successive cursor.execute() calls.

        Since few databases are able to process raw SQL scripts in a single
        cursor.execute() call and PEP 249 doesn't talk about this use case,
        the default implementation is conservative.
        T)strip_comments)sqlparsesplitformat)r(   r9   	statements      r)   prepare_sql_scriptz)BaseDatabaseOperations.prepare_sql_scriptc  s@     &^^C0
0	 OOId;0
 	
 
s    ;c                     |S )z
        Return the value of a CLOB column, for backends that return a locator
        object that requires additional processing.
        r-   r(   values     r)   process_clobz#BaseDatabaseOperations.process_clobr  s	    
 r+   c                      y)z
        For backends that support returning columns as part of an insert query,
        return the SQL and params to append to the INSERT query. The returned
        fragment should contain a format string to hold the appropriate column.
        Nr-   )r(   r3   s     r)   return_insert_columnsz,BaseDatabaseOperations.return_insert_columnsy  s     	r+   c                 z    | j                   t        | j                        | _         t        | j                   |      S )z
        Return the SQLCompiler class corresponding to the given name,
        in the namespace corresponding to the `compiler_module` attribute
        on this backend.
        )r'   r   compiler_modulegetattr)r(   compiler_names     r)   compilerzBaseDatabaseOperations.compiler  s1     ;;'(<(<=DKt{{M22r+   c                     t        d      )z
        Return a quoted version of the given table, index, or column name. Do
        not quote the given name if it's already been quoted.
        zFsubclasses of BaseDatabaseOperations may require a quote_name() methodr7   )r(   names     r)   r>   z!BaseDatabaseOperations.quote_name  s    
 "T
 	
r+   c                     t        d      )aG  
        Return the string to use in a query when performing regular expression
        lookups (using "regex" or "iregex"). It should contain a '%s'
        placeholder for the column being searched against.

        If the feature is not supported (or part of it is not supported), raise
        NotImplementedError.
        zHsubclasses of BaseDatabaseOperations may require a regex_lookup() methodr7   )r(   rG   s     r)   regex_lookupz#BaseDatabaseOperations.regex_lookup  s     "V
 	
r+   c                 *    d| j                  |      z  S )z
        Return the SQL for starting a new savepoint. Only required if the
        "uses_savepoints" feature is True. The "sid" parameter is a string
        for the savepoint id.
        zSAVEPOINT %sr=   r(   sids     r)   savepoint_create_sqlz+BaseDatabaseOperations.savepoint_create_sql  s      444r+   c                 *    d| j                  |      z  S )zD
        Return the SQL for committing the given savepoint.
        zRELEASE SAVEPOINT %sr=   r   s     r)   savepoint_commit_sqlz+BaseDatabaseOperations.savepoint_commit_sql  s     &(<<<r+   c                 *    d| j                  |      z  S )zF
        Return the SQL for rolling back the given savepoint.
        zROLLBACK TO SAVEPOINT %sr=   r   s     r)   savepoint_rollback_sqlz-BaseDatabaseOperations.savepoint_rollback_sql  s     *DOOC,@@@r+   c                      y)z
        Return the SQL that will set the connection's time zone.

        Return '' if the backend doesn't support time zones.
        r]   r-   r^   s    r)   set_time_zone_sqlz(BaseDatabaseOperations.set_time_zone_sql  s     r+   )reset_sequencesallow_cascadec                    t        d      )a  
        Return a list of SQL statements required to remove all data from
        the given database tables (without actually removing the tables
        themselves).

        The `style` argument is a Style object as returned by either
        color_style() or no_style() in django.core.management.color.

        If `reset_sequences` is True, the list includes SQL statements required
        to reset the sequences.

        The `allow_cascade` argument determines whether truncation may cascade
        to tables with foreign keys pointing the tables being truncated.
        PostgreSQL requires a cascade even if these tables are empty.
        zGsubclasses of BaseDatabaseOperations must provide an sql_flush() methodr7   )r(   styletablesr   r   s        r)   	sql_flushz BaseDatabaseOperations.sql_flush  s      "U
 	
r+   c                 P   t        j                  | j                  j                  | j                  j                  j
                        5  | j                  j                         5 }|D ]  }|j                  |        	 ddd       ddd       y# 1 sw Y   xY w# 1 sw Y   yxY w)z7Execute a list of SQL statements to flush the database.)using	savepointN)r   atomicr&   aliasfeaturescan_rollback_ddlre   execute)r(   sql_listre   r9   s       r)   execute_sql_flushz(BaseDatabaseOperations.execute_sql_flush  s}    //''oo..??
 '')V#CNN3' $ *	
 
 *)	
 
s$   
B%B?BB	BB%c                     g S )z
        Return a list of the SQL statements required to reset sequences
        passed in `sequences`.

        The `style` argument is a Style object as returned by either
        color_style() or no_style() in django.core.management.color.
        r-   )r(   r   	sequencess      r)   sequence_reset_by_name_sqlz1BaseDatabaseOperations.sequence_reset_by_name_sql  	     	r+   c                     g S )z
        Return a list of the SQL statements required to reset sequences for
        the given models.

        The `style` argument is a Style object as returned by either
        color_style() or no_style() in django.core.management.color.
        r-   )r(   r   
model_lists      r)   sequence_reset_sqlz)BaseDatabaseOperations.sequence_reset_sql  r   r+   c                      y)z9Return the SQL statement required to start a transaction.zBEGIN;r-   r^   s    r)   start_transaction_sqlz,BaseDatabaseOperations.start_transaction_sql  s    r+   c                 
    |syy)z7Return the SQL statement required to end a transaction.z	ROLLBACK;zCOMMIT;r-   )r(   successs     r)   end_transaction_sqlz*BaseDatabaseOperations.end_transaction_sql  s    r+   c                      y)a  
        Return the SQL that will be used in a query to define the tablespace.

        Return '' if the backend doesn't support tablespaces.

        If `inline` is True, append the SQL to a row; otherwise append it to
        the entire CREATE TABLE or CREATE INDEX statement.
        r]   r-   )r(   
tablespaceinlines      r)   tablespace_sqlz%BaseDatabaseOperations.tablespace_sql  s     r+   c                 x    t        |      j                  dd      j                  dd      j                  dd      S )z(Prepare a value for use in a LIKE query.\z\\%z\%_z\_)strr   )r(   xs     r)   prep_for_like_queryz*BaseDatabaseOperations.prep_for_like_query  s1    1v~~dF+33C?GGUSSr+   c                     |S )z
        Certain backends do not accept some values for "serial" fields
        (for example zero in MySQL). Raise a ValueError if the value is
        invalid, otherwise return the validated value.
        r-   r   s     r)   validate_autopk_valuez,BaseDatabaseOperations.validate_autopk_value  s	     r+   c                 ^   t        |t        j                        r| j                  |      S t        |t        j                        r| j	                  |      S t        |t        j
                        r| j                  |      S t        |t        j                        r| j                  |      S |S )a8  
        Transform a value to something compatible with the backend driver.

        This method only depends on the type of the value. It's designed for
        cases where the target type isn't known, such as .raw() SQL queries.
        As a consequence it may not work perfectly in all circumstances.
        )
r   datetimeadapt_datetimefield_valuedateadapt_datefield_valuetimeadapt_timefield_valuedecimalDecimaladapt_decimalfield_valuer   s     r)   adapt_unknown_valuez*BaseDatabaseOperations.adapt_unknown_value  s     eX../11%88x}}---e44x}}---e44w/0077Lr+   c                     |S r%   r-   )r(   r   rl   s      r)   adapt_integerfield_valuez/BaseDatabaseOperations.adapt_integerfield_value'  s    r+   c                     |yt        |      S )z
        Transform a date value to an object compatible with what is expected
        by the backend driver for date columns.
        Nr   r   s     r)   r  z,BaseDatabaseOperations.adapt_datefield_value*      
 =5zr+   c                     |yt        |      S )z
        Transform a datetime value to an object compatible with what is expected
        by the backend driver for datetime columns.
        Nr  r   s     r)   r  z0BaseDatabaseOperations.adapt_datetimefield_value3  r  r+   c                 ^    |yt        j                  |      rt        d      t        |      S )z
        Transform a time value to an object compatible with what is expected
        by the backend driver for time columns.
        Nz-Django does not support timezone-aware times.)r
   is_aware
ValueErrorr   r   s     r)   r  z,BaseDatabaseOperations.adapt_timefield_value<  s0    
 =U#LMM5zr+   c                 0    t        j                  |||      S )z
        Transform a decimal.Decimal value to an object compatible with what is
        expected by the backend driver for decimal (numeric) columns.
        )r   format_number)r(   r   
max_digitsdecimal_placess       r)   r  z/BaseDatabaseOperations.adapt_decimalfield_valueG  s    
 ""5*nEEr+   c                     |xs dS )z{
        Transform a string representation of an IP address into the expected
        type for the backend driver.
        Nr-   r   s     r)   adapt_ipaddressfield_valuez1BaseDatabaseOperations.adapt_ipaddressfield_valueN  s    
 }r+   c                 0    t        j                  ||      S )N)cls)jsondumps)r(   r   encoders      r)   adapt_json_valuez'BaseDatabaseOperations.adapt_json_valueU  s    zz%W--r+   c                 h   |r]t         j                  j                  |dd      }t         j                  j                  |dz   dd      t        j                  d      z
  }n.t        j                  |dd      }t        j                  |dd      }| j	                  |      }| j	                  |      }||gS )a9  
        Return a two-elements list with the lower and upper bound to be used
        with a BETWEEN operator to query a DateField value using a year
        lookup.

        `value` is an int, containing the looked-up year.
        If `iso_year` is True, return bounds for ISO-8601 week-numbering years.
           )days      )r   r  fromisocalendar	timedeltar  )r(   r   iso_yearfirstseconds        r)   !year_lookup_bounds_for_date_fieldz8BaseDatabaseOperations.year_lookup_bounds_for_date_fieldX  s     MM11%A>E]]22	1a""*+F MM%A.E]]5"b1F**51++F3vr+   c           	         |r]t         j                   j                  |dd      }t         j                   j                  |dz   dd      t        j                  d      z
  }n2t        j                   |dd      }t        j                   |dddddd      }t        j                  r@t        j                         }t        j                  ||      }t        j                  ||      }| j                  |      }| j                  |      }||gS )a=  
        Return a two-elements list with the lower and upper bound to be used
        with a BETWEEN operator to query a DateTimeField value using a year
        lookup.

        `value` is an int, containing the looked-up year.
        If `iso_year` is True, return bounds for ISO-8601 week-numbering years.
        r   )microsecondsr"  r#     ;   i?B )	r   r$  r%  r   USE_TZr
   get_current_timezone
make_awarer  )r(   r   r&  r'  r(  tzs         r)   %year_lookup_bounds_for_datetime_fieldz<BaseDatabaseOperations.year_lookup_bounds_for_datetime_fieldm  s     %%55eQBE&&66	1a""23F %%eQ2E&&ub"b"b&IF??..0B''r2E((4F..u5//7vr+   c                     g S )z
        Return a list of functions needed to convert field data.

        Some field types on some backends do not provide data in the correct
        format, this is the hook for converter functions.
        r-   r(   
expressions     r)   get_db_convertersz(BaseDatabaseOperations.get_db_converters  s	     	r+   c                 6    |t        j                  dd|      S y r~   )r   r%  )r(   r   r5  r&   s       r)   convert_durationfield_valuez2BaseDatabaseOperations.convert_durationfield_value  s"    %%aE22 r+   c                      y)a4  
        Check that the backend supports the provided expression.

        This is used on specific backends to rule out known expressions
        that have problematic or nonexistent implementations. If the
        expression has a known problem, the backend should raise
        NotSupportedError.
        Nr-   r4  s     r)   check_expression_supportz/BaseDatabaseOperations.check_expression_support  s     	r+   c                      y)zf
        Return True, if the conditional expression is supported in the WHERE
        clause.
        Tr-   r4  s     r)   0conditional_expression_supported_in_where_clausezGBaseDatabaseOperations.conditional_expression_supported_in_where_clause  r   r+   c                 .    d|z  }|j                  |      S )a   
        Combine a list of subexpressions into a single expression, using
        the provided connecting operator. This is required because operators
        can vary between backends (e.g., Oracle with %% and &) and between
        subexpression types (e.g., date expressions).
        z %s rv   )r(   	connectorsub_expressionsconns       r)   combine_expressionz)BaseDatabaseOperations.combine_expression  s     	!yy))r+   c                 &    | j                  ||      S r%   )rA  )r(   r>  r?  s      r)   combine_duration_expressionz2BaseDatabaseOperations.combine_duration_expression  s    &&y/BBr+   c                      y)z~
        Some backends require special syntax to insert binary content (MySQL
        for example uses '_binary %s').
        rA   r-   r   s     r)   binary_placeholder_sqlz-BaseDatabaseOperations.binary_placeholder_sql  r   r+   c                     |S )zs
        Allow modification of insert parameters. Needed for Oracle Spatial
        backend due to #10888.
        r-   )r(   placeholderrH   s      r)   modify_insert_paramsz+BaseDatabaseOperations.modify_insert_params  s	    
 r+   c                      | j                   |   S )z
        Given an integer field internal type (e.g. 'PositiveIntegerField'),
        return a tuple of the (min_value, max_value) form representing the
        range of the column type bound to the field.
        )integer_field_ranges)r(   rl   s     r)   integer_field_rangez*BaseDatabaseOperations.integer_field_range  s     ((77r+   c                     | j                   j                  j                  r|\  }}|\  }}d|d|dg ||fS t        d|z        )Nr   z - r   z-This backend does not support %s subtraction.)r&   r   supports_temporal_subtractionr   )r(   rl   lhsrhslhs_sql
lhs_paramsrhs_sql
rhs_paramss           r)   subtract_temporalsz)BaseDatabaseOperations.subtract_temporals  sY    ??##AA"%GZ"%GZ")735Oz5OJ5OOO;mK
 	
r+   c                     t        |t              rA|dk(  r| j                  S |dk  rdt        |      | j                  fz  S d|| j
                  fz  S y )Nr   z%d %s)r   intCURRENT_ROWabsr"   r#   r   s     r)   window_frame_valuez)BaseDatabaseOperations.window_frame_value  sW    eS!z'''#e*dnn!===%!888 "r+   c                 j   t        |t              r t        |t              r||kD  rt        d      |t        |t              st        d| d      |t        |t              st        d| d      | j                  |      xs | j                  }| j                  |      xs | j
                  }||fS )zU
        Return SQL for start and end points in an OVER clause window frame.
        z!start cannot be greater than end.z;start argument must be an integer, zero, or None, but got 'z'.z9end argument must be an integer, zero, or None, but got ')r   rV  r  rY  UNBOUNDED_PRECEDINGUNBOUNDED_FOLLOWING)r(   startendstart_end_s        r)   window_frame_rows_start_endz2BaseDatabaseOperations.window_frame_rows_start_end  s     eS!jc&:us{@AAZs%;MeWTVW  ?:c3#7KC5PRS  ((/K43K3K&&s+Gt/G/Gt|r+   c                    |t        |t              rt        |t              r|dkD  rt        d|z        |t        |t              rt        |t              r|dk  rt        d|z        | j                  |      xs | j                  }| j                  |      xs | j
                  }| j                  j                  }|j                  r0|r|dk  s|r'|dkD  r"t        d| j                  j                  z        ||fS )Nr   zGstart argument must be a negative integer, zero, or None, but got '%s'.zEend argument must be a positive integer, zero, or None, but got '%s'.zA%s only supports UNBOUNDED together with PRECEDING and FOLLOWING.)r   rV  r  rY  r[  r\  r&   r   4only_supports_unbounded_with_preceding_and_followingr   display_name)r(   r]  r^  r_  r`  r   s         r)   window_frame_range_start_endz3BaseDatabaseOperations.window_frame_range_start_end  s   j&<uc"uqy "'(  OJsC$8sC S1WW  ((/K43K3K&&s+Gt/G/G??++HHuqyccAg##;;<  t|r+   c           	         | j                   j                  j                  st        d      |r| j                   j                  j                  }|j                         }||vrZd|z  }|r+|ddj                  t        |            z  z  }t        |      |d| j                   j                   dz  }t        |      |r4t        ddj                  t        |j                                     z        | j                  S )Nz9This backend does not support explaining query execution.z%s is not a recognized format.z Allowed formats: %sru   r   z does not support any formats.zUnknown options: %s)r&   r   #supports_explaining_query_executionr   supported_explain_formatsupperrw   sortedrd  r  keysexplain_prefix)r(   r   optionssupported_formatsnormalized_formatmsgs         r)   explain_query_prefixz+BaseDatabaseOperations.explain_query_prefix  s    ''KK#K   $ 8 8 R R & (9969JJ$1DIIfEV>W4XXXC
 !o% DOO8899WXC !o%2TYYvglln?U5VVWW"""r+   c                      y)NzINSERT INTOr-   )r(   on_conflicts     r)   insert_statementz'BaseDatabaseOperations.insert_statement  s    r+   c                      y)Nr]   r-   )r(   r3   rs  update_fieldsunique_fieldss        r)   on_conflict_suffix_sqlz-BaseDatabaseOperations.on_conflict_suffix_sql  s    r+   c                 :    t        ||      }t        ||      }||fS r%   r   )r(   	lhs_table	lhs_field	rhs_table	rhs_fieldlhs_exprrhs_exprs          r)   prepare_join_on_clausez-BaseDatabaseOperations.prepare_join_on_clause"  s%    y),y),!!r+   r%   )FFr-   F)T)F)NN)]__name__
__module____qualname____doc__r   rJ  set_operatorscast_data_types"cast_char_field_without_max_lengthr"   r#   r[  r\  rW  rl  r*   r0   r5   r:   r?   rC   rI   rM   rP   rR   rT   rW   rY   r[   r_   rb   rg   rm   ro   rr   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r>   r   r   r   r   r   r   r   r   r   r   r   r   r   prep_for_iexact_queryr   r	  r  r  r  r  r  r  r  r)  r2  r6  r8  r:  r<  rA  rC  rE  rH  rK  rT  rY  ra  re  rq  rt  rx  r  r-   r+   r)   r   r      s   
 6O
 -1F#;%/ /).C
 #M O)-& II&2&2K N
	U



	
	

?$! 	


&
<0 

3

5=A ;@u 
((	T 0&	F.*23	*C8
9$6#*"r+   r   )r   r  r  ri   	importlibr   r   django.confr   	django.dbr   r   django.db.backendsr   django.db.models.expressionsr	   django.utilsr
   django.utils.deprecationr   django.utils.encodingr   r   r-   r+   r)   <module>r     s8        #    4 $ , ! = +T" T"r+   