Commit 714dec3e authored by François Ferry's avatar François Ferry
Browse files

refactor: remove sqlserver and mysql specific code

parent f71f0e2bc6d2
Pipeline #54101 passed with stages
in 39 minutes and 48 seconds
......@@ -730,21 +730,6 @@ class PostgresTestDataBaseHandler(TestDataBaseHandler):
self.dbcnx.commit()
# sqlserver2005 test database handling #########################################
class SQLServerTestDataBaseHandler(TestDataBaseHandler):
DRIVER = 'sqlserver'
# XXX complete me
def init_test_database(self):
"""initialize a fresh sqlserver databse used for testing purpose"""
if self.config.init_repository:
from cubicweb.server import init_repository
init_repository(self.config, interactive=False, drop=True,
init_config=self.init_config)
# sqlite test database handling ################################################
class SQLiteTestDataBaseHandler(TestDataBaseHandler):
......@@ -829,7 +814,6 @@ def register_handler(handlerkls, overwrite=False):
register_handler(PostgresTestDataBaseHandler)
register_handler(SQLiteTestDataBaseHandler)
register_handler(SQLServerTestDataBaseHandler)
class HCache(object):
......
......@@ -65,9 +65,9 @@ if applcubicwebversion < (3, 19, 0) and cubicwebversion >= (3, 19, 0):
if applcubicwebversion < (3, 18, 0) and cubicwebversion >= (3, 18, 0):
driver = config.system_source_config['db-driver']
if not (driver == 'postgres' or driver.startswith('sqlserver')):
if not driver == 'postgres':
import sys
print('This migration is not supported for backends other than sqlserver or postgres (yet).', file=sys.stderr)
print('This migration is not supported for backends other than postgres (yet).', file=sys.stderr)
sys.exit(1)
add_relation_definition('CWAttribute', 'add_permission', 'CWGroup')
......@@ -129,10 +129,7 @@ if applcubicwebversion < (3, 18, 0) and cubicwebversion >= (3, 18, 0):
sql(req, args, ask_confirm=False)
sql('ALTER TABLE cw_cwattribute DROP COLUMN cw_defaultval')
if driver == 'postgres':
sql('ALTER TABLE cw_cwattribute RENAME COLUMN new_defaultval TO cw_defaultval')
else: # sqlserver
sql("sp_rename 'cw_cwattribute.new_defaultval', 'cw_defaultval', 'COLUMN'")
sql('ALTER TABLE cw_cwattribute RENAME COLUMN new_defaultval TO cw_defaultval')
# Set object type to "Bytes" for CWAttribute's "defaultval" attribute
......@@ -180,19 +177,12 @@ if applcubicwebversion < (3, 18, 0) and cubicwebversion >= (3, 18, 0):
commit()
add_attribute('CWUniqueTogetherConstraint', 'name')
# low-level wipe code for postgres & sqlserver, plain sql ...
if driver == 'postgres':
for indexname, in sql('select indexname from pg_indexes'):
if indexname.startswith('unique_'):
print('dropping index', indexname)
sql('DROP INDEX %s' % indexname)
commit()
elif driver.startswith('sqlserver'):
for viewname, in sql('select name from sys.views'):
if viewname.startswith('utv_'):
print('dropping view (index should be cascade-deleted)', viewname)
sql('DROP VIEW %s' % viewname)
commit()
# low-level wipe code for postgres, plain sql ...
for indexname, in sql('select indexname from pg_indexes'):
if indexname.startswith('unique_'):
print('dropping index', indexname)
sql('DROP INDEX %s' % indexname)
commit()
# recreate the constraints, hook will lead to low-level recreation
for eschema in sorted(schema.entities()):
......
/* -*- sql -*-
mysql specific registered procedures,
*/
/* XXX limit_size version dealing with format as postgres version does.
XXX mysql doesn't support overloading, each function should have a different name
NOTE: fulltext renamed since it cause a mysql name conflict
*/
CREATE FUNCTION text_limit_size(vfulltext TEXT, maxsize INT)
RETURNS TEXT
NO SQL
BEGIN
IF LENGTH(vfulltext) < maxsize THEN
RETURN vfulltext;
ELSE
RETURN SUBSTRING(vfulltext from 1 for maxsize) || '...';
END IF;
END ;;
......@@ -361,7 +361,7 @@ class ServerMigrationHelper(MigrationHelper):
def cmd_install_custom_sql_scripts(self, cube=None):
"""install a cube custom sql scripts `schema/*.<driver>.sql` where
<driver> depends on the instance main database backend (eg 'postgres',
'mysql'...)
or 'sqlite')
"""
driver = self.repo.system_source.dbdriver
if cube is None:
......
......@@ -265,7 +265,7 @@ class NativeSQLSource(SQLAdapterMixIn, AbstractSource):
{'type': 'string',
'default': 'postgres',
# XXX use choice type
'help': 'database driver (postgres, sqlite, sqlserver2005)',
'help': 'database driver (postgres, sqlite)',
'group': 'native-source', 'level': 0,
}),
('db-host',
......@@ -719,7 +719,7 @@ class NativeSQLSource(SQLAdapterMixIn, AbstractSource):
if cls.__name__ == 'IntegrityError'):
# need string comparison because of various backends
for arg in ex.args:
# postgres, sqlserver
# postgres
mo = re.search("unique_[a-z0-9]{32}", arg)
if mo is not None:
raise UniqueTogetherError(cnx, cstrname=mo.group(0))
......
......@@ -39,7 +39,7 @@ _orig_check_permissions = ExecutionPlan._check_permissions
# add a dumb registered procedure
class stockproc(FunctionDescr):
supported_backends = ('postgres', 'sqlite', 'mysql')
supported_backends = ('postgres', 'sqlite')
try:
register_function(stockproc)
......
......@@ -67,7 +67,7 @@ password=admin
[system]
# database driver (postgres, sqlite, sqlserver2005)
# database driver (postgres, sqlite)
db-driver=postgres
# database host
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment