mirror of
https://github.com/silverstripe/silverstripe-sqlite3
synced 2024-10-22 17:05:37 +02:00
Defaulting to memory DB if 'path' not specified
Given that we're only using SQLite3 for testing, this is a reasonable default - and it means we don't need to have a special _config.php for CI.
This commit is contained in:
parent
589c35dfdb
commit
06f2559050
@ -18,20 +18,17 @@ class SQLitePDODatabase extends SQLite3Database {
|
|||||||
|
|
||||||
$dbName = !isset($this->database) ? $parameters['database'] : $dbName=$this->database;
|
$dbName = !isset($this->database) ? $parameters['database'] : $dbName=$this->database;
|
||||||
|
|
||||||
//assumes that the path to dbname will always be provided:
|
|
||||||
$file = $parameters['path'] . '/' . $dbName;
|
|
||||||
|
|
||||||
// use the very lightspeed SQLite In-Memory feature for testing
|
// use the very lightspeed SQLite In-Memory feature for testing
|
||||||
if(SapphireTest::using_temp_db() && $parameters['memory']) {
|
if((isset($parameters['memory']) && $parameters['memory']) || !isset($parameters['path'])) {
|
||||||
$file = ':memory:';
|
$file = ':memory:';
|
||||||
$this->lives_in_memory = true;
|
$this->lives_in_memory = true;
|
||||||
} else {
|
} else {
|
||||||
|
$file = $parameters['path'] . '/' . $dbName;
|
||||||
$this->lives_in_memory = false;
|
$this->lives_in_memory = false;
|
||||||
}
|
if(!file_exists($parameters['path'])) {
|
||||||
|
SQLiteDatabaseConfigurationHelper::create_db_dir($parameters['path']);
|
||||||
if(!file_exists($parameters['path'])) {
|
SQLiteDatabaseConfigurationHelper::secure_db_dir($parameters['path']);
|
||||||
SQLiteDatabaseConfigurationHelper::create_db_dir($parameters['path']);
|
}
|
||||||
SQLiteDatabaseConfigurationHelper::secure_db_dir($parameters['path']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->dbConn = new PDO("sqlite:$file");
|
$this->dbConn = new PDO("sqlite:$file");
|
||||||
|
Loading…
Reference in New Issue
Block a user