Compare commits
No commits in common. "3.0.0" and "2" have entirely different histories.
|
@ -9,21 +9,3 @@ jobs:
|
|||
ci:
|
||||
name: CI
|
||||
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1
|
||||
with:
|
||||
# set phpunit to false to prevent automatic generation of mysql phpunit jobs
|
||||
phpunit: false
|
||||
preserve_vendor_tests: true
|
||||
extra_jobs: |
|
||||
- php: 8.1
|
||||
db: sqlite3
|
||||
composer_args: --prefer-lowest
|
||||
phpunit: true
|
||||
phpunit_suite: all
|
||||
- php: 8.1
|
||||
db: sqlite3
|
||||
phpunit: true
|
||||
phpunit_suite: all
|
||||
- php: 8.2
|
||||
db: sqlite3
|
||||
phpunit: true
|
||||
phpunit_suite: all
|
||||
|
|
|
@ -8,11 +8,13 @@
|
|||
Andreas Piening (Nickname: apiening)
|
||||
<andreas (at) silverstripe (dot) com>
|
||||
|
||||
## Requirements
|
||||
|
||||
* Silverstripe 4.0 or newer
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
composer require silverstripe/sqlite3
|
||||
```
|
||||
* Install using composer with `composer require silverstripe/sqlite3 ^2`.
|
||||
|
||||
## Configuration
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<?php
|
|
@ -5,6 +5,7 @@ namespace SilverStripe\SQLite;
|
|||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\Core\Config\Configurable;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\Connect\Database;
|
||||
use SilverStripe\ORM\DataList;
|
||||
|
@ -119,6 +120,16 @@ class SQLite3Database extends Database
|
|||
*/
|
||||
public function connect($parameters)
|
||||
{
|
||||
if (!empty($parameters['memory'])) {
|
||||
Deprecation::notice(
|
||||
'1.4.0',
|
||||
"\$databaseConfig['memory'] is deprecated. Use \$databaseConfig['path'] = ':memory:' instead.",
|
||||
Deprecation::SCOPE_GLOBAL
|
||||
);
|
||||
unset($parameters['memory']);
|
||||
$parameters['path'] = ':memory:';
|
||||
}
|
||||
|
||||
//We will store these connection parameters for use elsewhere (ie, unit tests)
|
||||
$this->parameters = $parameters;
|
||||
$this->schemaManager->flushCache();
|
||||
|
@ -529,7 +540,7 @@ class SQLite3Database extends Database
|
|||
return $this->transactionNesting;
|
||||
}
|
||||
|
||||
public function transactionEnd(): bool|null
|
||||
public function transactionEnd($chain = false)
|
||||
{
|
||||
// Fail if transaction isn't available
|
||||
if (!$this->transactionDepth()) {
|
||||
|
@ -545,6 +556,10 @@ class SQLite3Database extends Database
|
|||
$this->resetTransactionNesting();
|
||||
}
|
||||
|
||||
if ($chain) {
|
||||
$this->transactionStart();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -607,6 +622,16 @@ class SQLite3Database extends Database
|
|||
return parent::preparedQuery($sql, $parameters, $errorLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inspect a SQL query prior to execution
|
||||
* @deprecated 2.2.0:3.0.0
|
||||
* @param string $sql
|
||||
*/
|
||||
protected function inspectQuery($sql)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
|
||||
public function clearTable($table)
|
||||
{
|
||||
$this->query("DELETE FROM \"$table\"");
|
||||
|
@ -627,9 +652,9 @@ class SQLite3Database extends Database
|
|||
// GLOB uses asterisks as wildcards.
|
||||
// Replace them in search string, without replacing escaped percetage signs.
|
||||
$comp = 'GLOB';
|
||||
$value = preg_replace('/^%([^\\\\])/', '*$1', $value ?? '');
|
||||
$value = preg_replace('/([^\\\\])%$/', '$1*', $value ?? '');
|
||||
$value = preg_replace('/([^\\\\])%/', '$1*', $value ?? '');
|
||||
$value = preg_replace('/^%([^\\\\])/', '*$1', $value);
|
||||
$value = preg_replace('/([^\\\\])%$/', '$1*', $value);
|
||||
$value = preg_replace('/([^\\\\])%/', '$1*', $value);
|
||||
} else {
|
||||
$comp = 'LIKE';
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace SilverStripe\SQLite;
|
|||
|
||||
use SilverStripe\ORM\Connect\Query;
|
||||
use SQLite3Result;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
* A result-set from a SQLite3 database.
|
||||
|
@ -44,6 +43,16 @@ class SQLite3Query extends Query
|
|||
}
|
||||
}
|
||||
|
||||
public function seek($row)
|
||||
{
|
||||
$this->handle->reset();
|
||||
$i=0;
|
||||
while ($i <= $row && $result = @$this->handle->fetchArray(SQLITE3_ASSOC)) {
|
||||
$i++;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo This looks terrible but there is no SQLite3::get_num_rows() implementation
|
||||
*/
|
||||
|
@ -53,7 +62,7 @@ class SQLite3Query extends Query
|
|||
if (!$this->handle->numColumns()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
$this->handle->reset();
|
||||
$c=0;
|
||||
while ($this->handle->fetchArray()) {
|
||||
|
@ -63,10 +72,12 @@ class SQLite3Query extends Query
|
|||
return $c;
|
||||
}
|
||||
|
||||
public function getIterator(): Traversable
|
||||
public function nextRecord()
|
||||
{
|
||||
while ($data = $this->handle->fetchArray(SQLITE3_ASSOC)) {
|
||||
yield $data;
|
||||
if ($data = $this->handle->fetchArray(SQLITE3_ASSOC)) {
|
||||
return $data;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -692,7 +692,7 @@ class SQLite3SchemaManager extends DBSchemaManager
|
|||
return (bool)$this->preparedQuery(
|
||||
'SELECT "name" FROM "sqlite_master" WHERE "type" = ? AND "name" = ?',
|
||||
array('table', $tableName)
|
||||
)->record();
|
||||
)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -715,7 +715,7 @@ class SQLite3SchemaManager extends DBSchemaManager
|
|||
$classnameinfo = $this->preparedQuery(
|
||||
"SELECT EnumList FROM SQLiteEnums WHERE TableColumn = ?",
|
||||
array($tablefield)
|
||||
)->record();
|
||||
)->first();
|
||||
if ($classnameinfo) {
|
||||
$valueList = $classnameinfo['EnumList'];
|
||||
$this->enum_map[$tablefield] = $valueList;
|
||||
|
|
|
@ -14,12 +14,11 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"silverstripe/framework": "^5",
|
||||
"silverstripe/vendor-plugin": "^2"
|
||||
"silverstripe/framework": "~4.0",
|
||||
"silverstripe/vendor-plugin": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"squizlabs/php_codesniffer": "^3",
|
||||
"phpunit/phpunit": "^9.5"
|
||||
"squizlabs/php_codesniffer": "^3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true">
|
||||
<testsuites>
|
||||
<testsuite name="framework">
|
||||
<directory>vendor/silverstripe/framework/tests/php</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
Loading…
Reference in New Issue