← Back
Editing: operations.cpython-311.pyc
� �|�eV: � �� � d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ d dl m Z d dlmZm Z mZ d dlmZ d dlmZ d d lmZ d d lmZmZmZ d dlmZ G d� d e� � ZdS )� N)� lru_cache)�chain)�settings)� FieldError)� DatabaseError�NotSupportedError�models)�BaseDatabaseOperations)�Col)�timezone)� parse_date�parse_datetime� parse_time)�cached_propertyc �( � � e Zd ZdZddd�ZdZd� Zd� Zd� Zd� Z d,d �Z d,d�Zd� Zd � Z d� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zed� � � Zddd�d�Zd� Zd� Zd� Z� fd�Zd � Zd!� Z d"� Z!d#� Z"d$� Z#d%� Z$d&� Z%� fd'�Z&d(� Z'd)� Z(d*� Z)d-� fd+� Z*� xZ+S ).�DatabaseOperations�text�TEXT)� DateField� DateTimeFieldzEXPLAIN QUERY PLANc � � t |� � dk rdS t |� � dk r!| j j j t |� � z S t |� � S )z� SQLite has a compile-time default (SQLITE_LIMIT_VARIABLE_NUMBER) of 999 variables per query. If there's only a single field to insert, the limit is 500 (SQLITE_MAX_COMPOUND_SELECT). � i� )�len� connection�features�max_query_params)�self�fields�objss �G/usr/lib/python3/dist-packages/django/db/backends/sqlite3/operations.py�bulk_batch_sizez"DatabaseOperations.bulk_batch_size sN � � �v�;�;�!����3� ��[�[�1�_�_��?�+�<��F���K�K��t�9�9�� c � � t j t j t j f}t j t j t j t j f}t ||� � rU|� � � D ]@} |j }t ||� � rt d� � ��*# t t f$ r Y �=w xY wt |t j � � r.|j r)t! |j � � dk rt d� � �d S d S d S )Nz{You cannot use Sum, Avg, StdDev, and Variance aggregations on date/time fields in sqlite3 since date/time is saved as text.r zTSQLite doesn't support DISTINCT on aggregate functions accepting multiple arguments.)r r r � TimeField�Sum�Avg�Variance�StdDev� isinstance�get_source_expressions�output_fieldr �AttributeErrorr � Aggregate�distinctr �source_expressions)r � expression� bad_fields�bad_aggregates�exprr+ s r �check_expression_supportz+DatabaseOperations.check_expression_support( s. � ��&��(<�f�>N�O� � �*�f�j�&�/�6�=�Q���j�.�1�1� �"�9�9�;�;� � ���#'�#4�L� "�,� �;�;� �/�@�� � ��� '� �3� � � � �D����� �z�6�#3�4�4� ��� � � �-�.�.��2�2�#�0�� � � � � � � 3�2s �9B � B4�3B4c �8 � d|� � � �d|�d�S )z� Support EXTRACT with a user-defined function django_date_extract() that's registered in connect(). Use single quotes because this is a string and could otherwise cause a collision with a field name. zdjango_date_extract('�', �)��lower�r �lookup_type� field_names r �date_extract_sqlz#DatabaseOperations.date_extract_sqlD s'