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
|
|
|
|
|
|
|
|
from .base import Database
|
|
|
|
|
|
|
|
|
|
|
|
class DatabaseFeatures(BaseDatabaseFeatures):
|
|
|
|
# SQLite cannot handle us only partially reading from a cursor's result set
|
|
|
|
# and then writing the same rows to the database in another cursor. This
|
|
|
|
# setting ensures we always read result sets fully into memory all in one
|
|
|
|
# go.
|
|
|
|
can_use_chunked_reads = False
|
|
|
|
test_db_allows_multiple_connections = False
|
|
|
|
supports_unspecified_pk = True
|
|
|
|
supports_timezones = False
|
|
|
|
supports_1000_query_parameters = False
|
|
|
|
supports_mixed_date_datetime_comparisons = False
|
|
|
|
has_bulk_insert = True
|
|
|
|
supports_foreign_keys = False
|
|
|
|
supports_column_check_constraints = False
|
|
|
|
autocommits_when_autocommit_is_off = True
|
|
|
|
can_introspect_decimal_field = False
|
|
|
|
can_introspect_positive_integer_field = True
|
|
|
|
can_introspect_small_integer_field = True
|
|
|
|
supports_transactions = True
|
|
|
|
atomic_transactions = False
|
|
|
|
can_rollback_ddl = True
|
|
|
|
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
|
2015-01-13 04:20:40 +08:00
|
|
|
|
|
|
|
@cached_property
|
|
|
|
def uses_savepoints(self):
|
|
|
|
return Database.sqlite_version_info >= (3, 6, 8)
|
|
|
|
|
2016-07-26 09:04:28 +08:00
|
|
|
@cached_property
|
|
|
|
def supports_index_column_ordering(self):
|
|
|
|
return Database.sqlite_version_info >= (3, 3, 0)
|
|
|
|
|
2015-01-13 04:20:40 +08:00
|
|
|
@cached_property
|
|
|
|
def can_release_savepoints(self):
|
|
|
|
return self.uses_savepoints
|
|
|
|
|
|
|
|
@cached_property
|
|
|
|
def can_share_in_memory_db(self):
|
|
|
|
return (
|
|
|
|
Database.__name__ == 'sqlite3.dbapi2' and
|
|
|
|
Database.sqlite_version_info >= (3, 7, 13)
|
|
|
|
)
|
|
|
|
|
|
|
|
@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
|