Compare commits
27 Commits
Author | SHA1 | Date |
---|---|---|
Maxime Rainville | a60fc4cf24 | |
Steve Boyd | d2fbce5319 | |
Steve Boyd | beb0f84f2d | |
Guy Sartorelli | 6d5c35116a | |
Steve Boyd | 41fd4718a2 | |
Steve Boyd | 448828c20a | |
Guy Sartorelli | faf9d033ff | |
Steve Boyd | d7b4ccb202 | |
Guy Sartorelli | c9bce8fe57 | |
Sabina Talipova | 4bbabf2421 | |
Steve Boyd | 22e3951244 | |
Steve Boyd | 321d0d853b | |
Guy Sartorelli | 84e13ffde3 | |
Steve Boyd | 17e9f5388c | |
Steve Boyd | 222f20529c | |
Steve Boyd | c46272e751 | |
Steve Boyd | afec73997a | |
Steve Boyd | d3c8e2915e | |
Steve Boyd | a709a741b0 | |
Maxime Rainville | dd4df9800b | |
Steve Boyd | 082742ad23 | |
Robbie Averill | a7c3450d43 | |
Robbie Averill | 0be39423a3 | |
Robbie Averill | 3d50b3f9ec | |
Ingo Schommer | 66376db094 | |
Sam Minnée | f2ec228c72 | |
Sam Minnee | 75f4a35f71 |
|
@ -0,0 +1,25 @@
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
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
|
||||||
|
extra_jobs: |
|
||||||
|
- php: 7.4
|
||||||
|
db: pgsql
|
||||||
|
phpunit: true
|
||||||
|
composer_args: --prefer-lowest
|
||||||
|
- php: 8.0
|
||||||
|
db: pgsql
|
||||||
|
phpunit: true
|
||||||
|
- php: 8.1
|
||||||
|
db: pgsql
|
||||||
|
phpunit: true
|
|
@ -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
|
|
@ -0,0 +1,17 @@
|
||||||
|
name: Keepalive
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
# The 4th of every month at 10:50am UTC
|
||||||
|
schedule:
|
||||||
|
- cron: '50 10 4 * *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
keepalive:
|
||||||
|
name: Keepalive
|
||||||
|
# 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: Keepalive
|
||||||
|
uses: silverstripe/gha-keepalive@v1
|
|
@ -1,15 +0,0 @@
|
||||||
inherit: true
|
|
||||||
|
|
||||||
build:
|
|
||||||
nodes:
|
|
||||||
analysis:
|
|
||||||
tests:
|
|
||||||
override: [php-scrutinizer-run]
|
|
||||||
|
|
||||||
checks:
|
|
||||||
php:
|
|
||||||
code_rating: true
|
|
||||||
duplication: true
|
|
||||||
|
|
||||||
filter:
|
|
||||||
paths: [code/*, tests/*]
|
|
53
.travis.yml
53
.travis.yml
|
@ -1,53 +0,0 @@
|
||||||
language: php
|
|
||||||
|
|
||||||
dist: xenial
|
|
||||||
|
|
||||||
services:
|
|
||||||
- postgresql
|
|
||||||
-
|
|
||||||
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- $HOME/.composer/cache/files
|
|
||||||
|
|
||||||
php:
|
|
||||||
- 7.1
|
|
||||||
|
|
||||||
env:
|
|
||||||
global:
|
|
||||||
- DB="PGSQL"
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
fast_finish: true
|
|
||||||
include:
|
|
||||||
- php: 7.1
|
|
||||||
env:
|
|
||||||
- PHPUNIT_TEST=framework
|
|
||||||
- php: 7.2
|
|
||||||
env:
|
|
||||||
- PHPUNIT_TEST=framework
|
|
||||||
- php: 7.3
|
|
||||||
env:
|
|
||||||
- PHPUNIT_TEST=framework
|
|
||||||
- php: 7.1
|
|
||||||
env:
|
|
||||||
- PHPUNIT_TEST=postgresql
|
|
||||||
- PHPCS_TEST=1
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
# Init PHP
|
|
||||||
- phpenv rehash
|
|
||||||
- phpenv config-rm xdebug.ini
|
|
||||||
- export PATH=~/.composer/vendor/bin:$PATH
|
|
||||||
- echo 'memory_limit = 2048M' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
|
|
||||||
|
|
||||||
# Install composer dependencies
|
|
||||||
- composer validate
|
|
||||||
- composer require --no-update silverstripe/recipe-cms:4.3.x-dev
|
|
||||||
- composer install --prefer-source --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile
|
|
||||||
- if [[ $PHPCS_TEST ]]; then composer global require squizlabs/php_codesniffer:^3 --prefer-dist --no-interaction --no-progress --no-suggest -o; fi
|
|
||||||
|
|
||||||
script:
|
|
||||||
- if [[ $PHPUNIT_TEST == postgresql ]]; then vendor/bin/phpunit ./tests; fi
|
|
||||||
- if [[ $PHPUNIT_TEST == framework ]]; then vendor/bin/phpunit ./vendor/silverstripe/framework/tests/php; fi
|
|
||||||
- if [[ $PHPCS_TEST ]]; then composer run-script lint; fi
|
|
16
README.md
16
README.md
|
@ -1,15 +1,11 @@
|
||||||
# PostgreSQL Module Module
|
# PostgreSQL Module Module
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/silverstripe/silverstripe-postgresql.png?branch=master)](https://travis-ci.org/silverstripe/silverstripe-postgresql)
|
[![CI](https://github.com/silverstripe/silverstripe-postgresql/actions/workflows/ci.yml/badge.svg)](https://github.com/silverstripe/silverstripe-postgresql/actions/workflows/ci.yml)
|
||||||
[![SilverStripe supported module](https://img.shields.io/badge/silverstripe-supported-0071C4.svg)](https://www.silverstripe.org/software/addons/silverstripe-commercially-supported-module-list/)
|
[![Silverstripe supported module](https://img.shields.io/badge/silverstripe-supported-0071C4.svg)](https://www.silverstripe.org/software/addons/silverstripe-commercially-supported-module-list/)
|
||||||
|
|
||||||
## Maintainer Contact
|
|
||||||
|
|
||||||
* Sam Minnee (Nickname: sminnee) <sam@silverstripe.com>
|
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
* SilverStripe 4.0
|
* Silverstripe 4.0
|
||||||
* PostgreSQL >=9.2
|
* PostgreSQL >=9.2
|
||||||
* Note: PostgreSQL 10 has not been tested
|
* Note: PostgreSQL 10 has not been tested
|
||||||
|
|
||||||
|
@ -47,6 +43,12 @@ See [docs/en](docs/en/README.md) for more information about configuring the modu
|
||||||
All column and table names must be double-quoted. PostgreSQL automatically
|
All column and table names must be double-quoted. PostgreSQL automatically
|
||||||
lower-cases columns, and your queries will fail if you don't.
|
lower-cases columns, and your queries will fail if you don't.
|
||||||
|
|
||||||
|
Collations have known issues when installed on Alpine, MacOS X and BSD derivatives
|
||||||
|
(see [PostgreSQL FAQ](https://wiki.postgresql.org/wiki/FAQ#Why_do_my_strings_sort_incorrectly.3F)).
|
||||||
|
We do not support such installations, although they still may work correctly for you.
|
||||||
|
As a workaround for PostgreSQL 10+ you could manually switch to ICU collations (e.g. und-x-icu).
|
||||||
|
There are no known workarounds for PostgreSQL <10.
|
||||||
|
|
||||||
Ts_vector columns are not automatically detected by the built-in search
|
Ts_vector columns are not automatically detected by the built-in search
|
||||||
filters. That means if you're doing a search through the CMS on a ModelAdmin
|
filters. That means if you're doing a search through the CMS on a ModelAdmin
|
||||||
object, it will use LIKE queries which are very slow. If you're writing your
|
object, it will use LIKE queries which are very slow. If you're writing your
|
||||||
|
|
|
@ -58,8 +58,10 @@ class PostgreSQLQuery extends Query
|
||||||
|
|
||||||
public function seek($row)
|
public function seek($row)
|
||||||
{
|
{
|
||||||
pg_result_seek($this->handle, $row);
|
// Specifying the zero-th record here will reset the pointer
|
||||||
return $this->nextRecord();
|
$result = pg_fetch_array($this->handle, $row, PGSQL_NUM);
|
||||||
|
|
||||||
|
return $this->parseResult($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function numRecords()
|
public function numRecords()
|
||||||
|
@ -73,26 +75,35 @@ class PostgreSQLQuery extends Query
|
||||||
|
|
||||||
// Correct non-string types
|
// Correct non-string types
|
||||||
if ($row) {
|
if ($row) {
|
||||||
$record = [];
|
return $this->parseResult($row);
|
||||||
|
|
||||||
foreach ($row as $i => $v) {
|
|
||||||
$k = $this->columnNames[$i];
|
|
||||||
$record[$k] = $v;
|
|
||||||
$type = pg_field_type($this->handle, $i);
|
|
||||||
if (isset(self::$typeMapping[$type])) {
|
|
||||||
if ($type === 'bool' && $record[$k] === 't') {
|
|
||||||
$record[$k] = 1;
|
|
||||||
|
|
||||||
// Note that boolean 'f' will be converted to 0 by this
|
|
||||||
} else {
|
|
||||||
settype($record[$k], self::$typeMapping[$type]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $record;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $row
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function parseResult(array $row)
|
||||||
|
{
|
||||||
|
$record = [];
|
||||||
|
|
||||||
|
foreach ($row as $i => $v) {
|
||||||
|
$k = $this->columnNames[$i];
|
||||||
|
$record[$k] = $v;
|
||||||
|
$type = pg_field_type($this->handle, $i);
|
||||||
|
if (isset(self::$typeMapping[$type])) {
|
||||||
|
if ($type === 'bool' && $record[$k] === 't') {
|
||||||
|
$record[$k] = 1;
|
||||||
|
|
||||||
|
// Note that boolean 'f' will be converted to 0 by this
|
||||||
|
} else {
|
||||||
|
settype($record[$k], self::$typeMapping[$type]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $record;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -858,7 +858,9 @@ class PostgreSQLSchemaManager extends DBSchemaManager
|
||||||
$argList = array();
|
$argList = array();
|
||||||
$nextArg = "";
|
$nextArg = "";
|
||||||
foreach ($bytes as $byte) {
|
foreach ($bytes as $byte) {
|
||||||
if ($byte == "00") {
|
if ($byte == '\x') {
|
||||||
|
continue;
|
||||||
|
} elseif ($byte == "00") {
|
||||||
$argList[] = $nextArg;
|
$argList[] = $nextArg;
|
||||||
$nextArg = "";
|
$nextArg = "";
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -19,12 +19,8 @@
|
||||||
"silverstripe/vendor-plugin": "^1.0"
|
"silverstripe/vendor-plugin": "^1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^5.7"
|
"phpunit/phpunit": "^9.5",
|
||||||
},
|
"squizlabs/php_codesniffer": "^3"
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"2.x-dev": "2.4.x-dev"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
<ruleset name="SilverStripe">
|
<ruleset name="SilverStripe">
|
||||||
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>
|
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>
|
||||||
|
|
||||||
|
<file>code</file>
|
||||||
|
<file>tests</file>
|
||||||
|
|
||||||
<!-- base rules are PSR-2 -->
|
<!-- base rules are PSR-2 -->
|
||||||
<rule ref="PSR2" >
|
<rule ref="PSR2" >
|
||||||
<!-- Current exclusions -->
|
<!-- Current exclusions -->
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true">
|
<phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true">
|
||||||
|
|
||||||
<testsuite name="Default">
|
<testsuite name="Default">
|
||||||
|
|
Loading…
Reference in New Issue