Compare commits
2 Commits
3.0.0-beta
...
2
Author | SHA1 | Date |
---|---|---|
Maxime Rainville | a60fc4cf24 | |
Steve Boyd | d2fbce5319 |
|
@ -4,32 +4,22 @@ on:
|
|||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
# Every Thursday at 12:20pm UTC
|
||||
schedule:
|
||||
- cron: '20 12 * * 4'
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
name: CI
|
||||
# Only run cron on the silverstripe account
|
||||
if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule')
|
||||
uses: "silverstripe/gha-ci/.github/workflows/ci.yml@v1"
|
||||
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
|
||||
- php: 7.4
|
||||
db: pgsql
|
||||
phpunit: true
|
||||
composer_args: --prefer-lowest
|
||||
phpunit_suite: all
|
||||
- php: 8.0
|
||||
db: pgsql
|
||||
phpunit: true
|
||||
- php: 8.1
|
||||
db: pgsql
|
||||
phpunit: true
|
||||
phpunit_suite: all
|
||||
- php: 8.2
|
||||
db: pgsql
|
||||
phpunit: true
|
||||
phpunit_suite: all
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
name: Dispatch CI
|
||||
|
||||
on:
|
||||
# At 12:20 PM UTC, only on Thursday and Friday
|
||||
schedule:
|
||||
- cron: '20 12 * * 4,5'
|
||||
|
||||
jobs:
|
||||
dispatch-ci:
|
||||
name: Dispatch CI
|
||||
# Only run cron on the silverstripe account
|
||||
if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Dispatch CI
|
||||
uses: silverstripe/gha-dispatch-ci@v1
|
|
@ -11,6 +11,9 @@ use ErrorException;
|
|||
* The connector doesn't know anything about schema selection, so code related to
|
||||
* masking multiple databases as schemas should be handled in the database controller
|
||||
* and schema manager.
|
||||
*
|
||||
* @package sapphire
|
||||
* @subpackage model
|
||||
*/
|
||||
class PostgreSQLConnector extends DBConnector
|
||||
{
|
||||
|
@ -113,7 +116,8 @@ class PostgreSQLConnector extends DBConnector
|
|||
|
||||
public function getGeneratedID($table)
|
||||
{
|
||||
return $this->query("SELECT currval('\"{$table}_ID_seq\"')")->value();
|
||||
$result = $this->query("SELECT currval('\"{$table}_ID_seq\"')")->first();
|
||||
return $result['currval'];
|
||||
}
|
||||
|
||||
public function getLastError()
|
||||
|
|
|
@ -574,14 +574,13 @@ class PostgreSQLDatabase extends Database
|
|||
return $this->transactionNesting;
|
||||
}
|
||||
|
||||
public function transactionEnd($chain = false): ?bool
|
||||
public function transactionEnd($chain = false)
|
||||
{
|
||||
--$this->transactionNesting;
|
||||
if ($this->transactionNesting <= 0) {
|
||||
$this->transactionNesting = 0;
|
||||
$this->query('COMMIT;');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function comparisonClause($field, $value, $exact = false, $negate = false, $caseSensitive = null, $parameterised = false)
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace SilverStripe\PostgreSQL;
|
||||
|
||||
use Iterator;
|
||||
use SilverStripe\ORM\Connect\Query;
|
||||
|
||||
/**
|
||||
|
@ -57,13 +56,12 @@ class PostgreSQLQuery extends Query
|
|||
}
|
||||
}
|
||||
|
||||
public function getIterator(): Iterator
|
||||
public function seek($row)
|
||||
{
|
||||
while ($row = pg_fetch_array($this->handle, null, PGSQL_NUM)) {
|
||||
yield $this->parseResult($row);
|
||||
}
|
||||
// Reset so the query can be iterated over again
|
||||
pg_result_seek($this->handle, 0);
|
||||
// Specifying the zero-th record here will reset the pointer
|
||||
$result = pg_fetch_array($this->handle, $row, PGSQL_NUM);
|
||||
|
||||
return $this->parseResult($result);
|
||||
}
|
||||
|
||||
public function numRecords()
|
||||
|
@ -71,6 +69,18 @@ class PostgreSQLQuery extends Query
|
|||
return pg_num_rows($this->handle);
|
||||
}
|
||||
|
||||
public function nextRecord()
|
||||
{
|
||||
$row = pg_fetch_array($this->handle, null, PGSQL_NUM);
|
||||
|
||||
// Correct non-string types
|
||||
if ($row) {
|
||||
return $this->parseResult($row);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $row
|
||||
* @return array
|
||||
|
|
|
@ -79,7 +79,7 @@ class PostgreSQLSchemaManager extends DBSchemaManager
|
|||
public function postgresDatabaseExists($name)
|
||||
{
|
||||
$result = $this->preparedQuery("SELECT datname FROM pg_database WHERE datname = ?;", array($name));
|
||||
return $result->value() ? true : false;
|
||||
return $result->first() ? true : false;
|
||||
}
|
||||
|
||||
public function databaseExists($name)
|
||||
|
@ -146,7 +146,7 @@ class PostgreSQLSchemaManager extends DBSchemaManager
|
|||
return $this->preparedQuery(
|
||||
"SELECT nspname FROM pg_catalog.pg_namespace WHERE nspname = ?;",
|
||||
array($name)
|
||||
)->value() ? true : false;
|
||||
)->first() ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -462,18 +462,18 @@ class PostgreSQLSchemaManager extends DBSchemaManager
|
|||
$stats = $this->preparedQuery(
|
||||
"SELECT relid FROM pg_stat_user_tables WHERE relname = ?;",
|
||||
array($table)
|
||||
)->record();
|
||||
)->first();
|
||||
$oid = $stats['relid'];
|
||||
|
||||
//Now we can run a long query to get the clustered status:
|
||||
//If anyone knows a better way to get the clustered status, then feel free to replace this!
|
||||
$clustered = $this->preparedQuery(
|
||||
"
|
||||
SELECT c2.relname, i.indisclustered
|
||||
SELECT c2.relname, i.indisclustered
|
||||
FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i
|
||||
WHERE c.oid = ? AND c.oid = i.indrelid AND i.indexrelid = c2.oid AND indisclustered='t';",
|
||||
array($oid)
|
||||
)->value();
|
||||
)->first();
|
||||
|
||||
if ($clustered) {
|
||||
$this->query("ALTER TABLE \"$table\" SET WITHOUT CLUSTER;");
|
||||
|
@ -830,9 +830,9 @@ class PostgreSQLSchemaManager extends DBSchemaManager
|
|||
protected function extractTriggerColumns($triggerName, $table)
|
||||
{
|
||||
$trigger = $this->preparedQuery(
|
||||
"SELECT t.tgargs
|
||||
"SELECT t.tgargs
|
||||
FROM pg_catalog.pg_trigger t
|
||||
INNER JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid
|
||||
INNER JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid
|
||||
INNER JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
||||
WHERE c.relname = ?
|
||||
AND n.nspname = ?
|
||||
|
@ -842,7 +842,7 @@ class PostgreSQLSchemaManager extends DBSchemaManager
|
|||
$this->database->currentSchema(),
|
||||
$triggerName
|
||||
]
|
||||
)->record();
|
||||
)->first();
|
||||
|
||||
// Convert stream to string
|
||||
if (is_resource($trigger['tgargs'])) {
|
||||
|
@ -968,7 +968,7 @@ class PostgreSQLSchemaManager extends DBSchemaManager
|
|||
WHERE r.contype = 'c' AND conname = ? AND n.nspname = ?
|
||||
ORDER BY 1;",
|
||||
array($constraint, $this->database->currentSchema())
|
||||
)->record();
|
||||
)->first();
|
||||
if (!$cache) {
|
||||
return $value;
|
||||
}
|
||||
|
@ -1048,7 +1048,7 @@ class PostgreSQLSchemaManager extends DBSchemaManager
|
|||
FROM information_schema.triggers
|
||||
WHERE trigger_name = ? AND trigger_schema = ?;",
|
||||
array($triggerName, $this->database->currentSchema())
|
||||
)->value();
|
||||
)->first();
|
||||
if ($exists) {
|
||||
$this->query("DROP trigger IF EXISTS $triggerName ON \"$tableName\";");
|
||||
}
|
||||
|
@ -1364,7 +1364,7 @@ class PostgreSQLSchemaManager extends DBSchemaManager
|
|||
$existing = $this->preparedQuery(
|
||||
"SELECT spcname, spclocation FROM pg_tablespace WHERE spcname = ?;",
|
||||
array($name)
|
||||
)->record();
|
||||
)->first();
|
||||
|
||||
//NOTE: this location must be empty for this to work
|
||||
//We can't seem to change the location of the tablespace through any ALTER commands :(
|
||||
|
@ -1489,7 +1489,7 @@ class PostgreSQLSchemaManager extends DBSchemaManager
|
|||
$result = $this->preparedQuery(
|
||||
"SELECT lanname FROM pg_language WHERE lanname = ?;",
|
||||
array($language)
|
||||
)->value();
|
||||
)->first();
|
||||
|
||||
if (!$result) {
|
||||
$this->query("CREATE LANGUAGE $language;");
|
||||
|
|
|
@ -15,9 +15,8 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"silverstripe/framework": "^5",
|
||||
"silverstripe/vendor-plugin": "^2",
|
||||
"ext-pgsql": "*"
|
||||
"silverstripe/framework": "^4",
|
||||
"silverstripe/vendor-plugin": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.5",
|
||||
|
|
|
@ -1,9 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true">
|
||||
<testsuites>
|
||||
<testsuite name="postgresql">
|
||||
<directory>tests</directory>
|
||||
<directory>vendor/silverstripe/framework/tests/php</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<testsuite name="Default">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
|
||||
<filter>
|
||||
<whitelist addUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">.</directory>
|
||||
<exclude>
|
||||
<directory suffix=".php">tests/</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
||||
</phpunit>
|
||||
|
|
Loading…
Reference in New Issue