Set a minimal supported version of sqlite
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Set minimal supported version of SQLite to 3.30.1
|
||||
* Refactor of trytond.config to add cache
|
||||
* Handle URL host of the bus on login
|
||||
* Restrict sessions to the client's IP address
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
import sqlite3
|
||||
import sys
|
||||
|
||||
from .database import (
|
||||
Database, DatabaseDataError, DatabaseIntegrityError,
|
||||
DatabaseOperationalError, DatabaseTimeoutError)
|
||||
from .table import TableHandler
|
||||
|
||||
if sqlite3.sqlite_version_info < (3, 30, 1):
|
||||
sys.exit("Tryton sqlite backend requires version 3.30.1 or higher")
|
||||
|
||||
__all__ = [
|
||||
Database, TableHandler,
|
||||
DatabaseIntegrityError, DatabaseDataError, DatabaseOperationalError,
|
||||
|
||||
@@ -238,10 +238,6 @@ class SQLitePosition(Function):
|
||||
return 0
|
||||
|
||||
|
||||
def replace(text, pattern, replacement):
|
||||
return str(text).replace(pattern, replacement)
|
||||
|
||||
|
||||
def now():
|
||||
transaction = Transaction()
|
||||
return _nows.setdefault(transaction, {}).setdefault(
|
||||
@@ -443,8 +439,7 @@ class Database(DatabaseInterface):
|
||||
_list_cache_timestamp = {}
|
||||
flavor = Flavor(
|
||||
paramstyle='qmark', function_mapping=MAPPING, null_ordering=False,
|
||||
max_limit=-1,
|
||||
filter_=sqlite.sqlite_version_info >= (3, 30, 0))
|
||||
max_limit=-1, filter_=True)
|
||||
IN_MAX = 200
|
||||
|
||||
TYPES_MAPPING = {
|
||||
@@ -477,8 +472,6 @@ class Database(DatabaseInterface):
|
||||
self._conn.create_function('date_trunc', 2, date_trunc)
|
||||
self._conn.create_function('split_part', 3, split_part)
|
||||
self._conn.create_function('to_char', 2, to_char)
|
||||
if sqlite.sqlite_version_info < (3, 3, 14):
|
||||
self._conn.create_function('replace', 3, replace)
|
||||
self._conn.create_function('now', 0, now)
|
||||
self._conn.create_function('greatest', -1, greatest)
|
||||
self._conn.create_function('least', -1, least)
|
||||
|
||||
@@ -113,14 +113,11 @@ class TableHandler(TableHandlerInterface):
|
||||
cursor = Transaction().connection.cursor()
|
||||
if self.column_exist(old_name):
|
||||
if not self.column_exist(new_name):
|
||||
if sqlite.sqlite_version_info >= (3, 25, 0):
|
||||
cursor.execute('ALTER TABLE %s RENAME COLUMN %s TO %s' % (
|
||||
_escape_identifier(self.table_name),
|
||||
_escape_identifier(old_name),
|
||||
_escape_identifier(new_name)))
|
||||
self._update_definitions(columns=True)
|
||||
else:
|
||||
self._recreate_table({old_name: {'name': new_name}})
|
||||
cursor.execute('ALTER TABLE %s RENAME COLUMN %s TO %s' % (
|
||||
_escape_identifier(self.table_name),
|
||||
_escape_identifier(old_name),
|
||||
_escape_identifier(new_name)))
|
||||
self._update_definitions(columns=True)
|
||||
else:
|
||||
logger.warning(
|
||||
'Unable to rename column %s on table %s to %s.',
|
||||
|
||||
Reference in New Issue
Block a user