2018-10-26 07:54:48 +08:00
|
|
|
import sys
|
|
|
|
|
2015-01-13 04:20:40 +08:00
|
|
|
from django.db import utils
|
|
|
|
from django.db.backends.base.features import BaseDatabaseFeatures
|
|
|
|
from django.utils.functional import cached_property
|
|
|
|
|
2018-10-25 19:22:40 +08:00
|
|
|
from .base import Database
|
|
|
|
|
2015-01-13 04:20:40 +08:00
|
|
|
|
|
|
|
class DatabaseFeatures(BaseDatabaseFeatures):
|
2018-07-21 02:57:17 +08:00
|
|
|
# SQLite can read from a cursor since SQLite 3.6.5, subject to the caveat
|
|
|
|
# that statements within a connection aren't isolated from each other. See
|
|
|
|
# https://sqlite.org/isolation.html.
|
|
|
|
can_use_chunked_reads = True
|
2015-01-13 04:20:40 +08:00
|
|
|
test_db_allows_multiple_connections = False
|
|
|
|
supports_unspecified_pk = True
|
|
|
|
supports_timezones = False
|
2017-03-25 01:37:03 +08:00
|
|
|
max_query_params = 999
|
2015-01-13 04:20:40 +08:00
|
|
|
supports_mixed_date_datetime_comparisons = False
|
2018-10-26 07:54:48 +08:00
|
|
|
autocommits_when_autocommit_is_off = sys.version_info < (3, 6)
|
2015-01-13 04:20:40 +08:00
|
|
|
can_introspect_decimal_field = False
|
2018-10-21 15:08:05 +08:00
|
|
|
can_introspect_duration_field = False
|
2015-01-13 04:20:40 +08:00
|
|
|
can_introspect_positive_integer_field = True
|
|
|
|
can_introspect_small_integer_field = True
|
|
|
|
supports_transactions = True
|
|
|
|
atomic_transactions = False
|
|
|
|
can_rollback_ddl = True
|
2018-12-11 16:06:24 +08:00
|
|
|
supports_atomic_references_rename = Database.version_info >= (3, 26, 0)
|
2015-01-13 04:20:40 +08:00
|
|
|
supports_paramstyle_pyformat = False
|
|
|
|
supports_sequence_reset = False
|
2015-09-06 17:12:08 +08:00
|
|
|
can_clone_databases = True
|
2016-01-20 09:43:41 +08:00
|
|
|
supports_temporal_subtraction = True
|
2016-11-29 02:29:21 +08:00
|
|
|
ignores_table_name_case = True
|
2017-07-18 03:12:27 +08:00
|
|
|
supports_cast_with_precision = False
|
2018-09-18 19:59:10 +08:00
|
|
|
time_cast_precision = 3
|
2017-10-03 22:42:18 +08:00
|
|
|
can_release_savepoints = True
|
2018-09-13 15:34:02 +08:00
|
|
|
supports_partial_indexes = Database.version_info >= (3, 8, 0)
|
2018-10-25 19:22:40 +08:00
|
|
|
# Is "ALTER TABLE ... RENAME COLUMN" supported?
|
|
|
|
can_alter_table_rename_column = Database.sqlite_version_info >= (3, 25, 0)
|
2018-12-03 06:17:32 +08:00
|
|
|
supports_parentheses_in_compound = False
|
2015-01-13 04:20:40 +08:00
|
|
|
|
|
|
|
@cached_property
|
|
|
|
def supports_stddev(self):
|
2017-01-25 07:04:12 +08:00
|
|
|
"""
|
|
|
|
Confirm support for STDDEV and related stats functions.
|
2015-01-13 04:20:40 +08:00
|
|
|
|
|
|
|
SQLite supports STDDEV as an extension package; so
|
2015-01-17 13:03:46 +08:00
|
|
|
connection.ops.check_expression_support() can't unilaterally
|
2017-01-25 07:04:12 +08:00
|
|
|
rule out support for STDDEV. Manually check whether the call works.
|
2015-01-13 04:20:40 +08:00
|
|
|
"""
|
|
|
|
with self.connection.cursor() as cursor:
|
|
|
|
cursor.execute('CREATE TABLE STDDEV_TEST (X INT)')
|
|
|
|
try:
|
|
|
|
cursor.execute('SELECT STDDEV(*) FROM STDDEV_TEST')
|
|
|
|
has_support = True
|
|
|
|
except utils.DatabaseError:
|
|
|
|
has_support = False
|
|
|
|
cursor.execute('DROP TABLE STDDEV_TEST')
|
|
|
|
return has_support
|