mirror of
https://github.com/silverstripe/silverstripe-sqlite3
synced 2024-10-22 15:05:37 +00:00
API Don't run in-memory by default.
While the SQLite3 module is predominantly used for testing, its best to leave this decision to the code using it. We should default to a conservative setting (slower, but persistent). Also remove coupling to SapphireTest when setting this value. Don't bother creating the directory if running in-memory.
This commit is contained in:
parent
7061e7a7c6
commit
14601368b8
@ -10,7 +10,6 @@ if(defined('SS_DATABASE_CLASS') && in_array(SS_DATABASE_CLASS, $classes)) {
|
||||
if(in_array($databaseConfig['type'], $classes)) {
|
||||
if(empty($databaseConfig['path'])) $databaseConfig['path'] = defined('SS_SQLITE_DATABASE_PATH') && SS_SQLITE_DATABASE_PATH ? SS_SQLITE_DATABASE_PATH : ASSETS_PATH . '/.sqlitedb/'; // where to put the database file
|
||||
$databaseConfig['database'] = (defined('SS_DATABASE_PREFIX') ? SS_DATABASE_PREFIX : '') . $databaseConfig['database'] . (defined('SS_DATABASE_SUFFIX') ? SS_DATABASE_SUFFIX : '');
|
||||
if(!isset($databaseConfig['memory'])) $databaseConfig['memory'] = true; // run tests in memory
|
||||
if(empty($databaseConfig['key'])) $databaseConfig['key'] = defined('SS_SQLITE_DATABASE_KEY') && SS_SQLITE_DATABASE_KEY ? SS_SQLITE_DATABASE_KEY : 'SQLite3DatabaseKey';
|
||||
|
||||
/**
|
||||
|
@ -76,18 +76,17 @@ class SQLite3Database extends SS_Database {
|
||||
$file = $parameters['path'] . '/' . $dbName;
|
||||
|
||||
// use the very lightspeed SQLite In-Memory feature for testing
|
||||
if(SapphireTest::using_temp_db() && $parameters['memory']) {
|
||||
if(isset($parameters['memory']) && $parameters['memory']) {
|
||||
$file = ':memory:';
|
||||
$this->lives_in_memory = true;
|
||||
} else {
|
||||
$this->lives_in_memory = false;
|
||||
if(!file_exists($parameters['path'])) {
|
||||
SQLiteDatabaseConfigurationHelper::create_db_dir($parameters['path']);
|
||||
SQLiteDatabaseConfigurationHelper::secure_db_dir($parameters['path']);
|
||||
}
|
||||
}
|
||||
|
||||
if(!file_exists($parameters['path'])) {
|
||||
SQLiteDatabaseConfigurationHelper::create_db_dir($parameters['path']);
|
||||
SQLiteDatabaseConfigurationHelper::secure_db_dir($parameters['path']);
|
||||
}
|
||||
|
||||
$this->dbConn = new SQLite3($file, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE, $parameters['key']);
|
||||
if(method_exists('SQLite3', 'busyTimeout')) $this->dbConn->busyTimeout(60000);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user