Skip to content

Commit

Permalink
Merge pull request #7210 from nextcloud/pg10
Browse files Browse the repository at this point in the history
add postgresql 10 compatibility to dbal
  • Loading branch information
MorrisJobke authored Nov 27, 2017
2 parents e428ef9 + b331c67 commit 4a63727
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 121 deletions.
22 changes: 21 additions & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ pipeline:
matrix:
DB: postgres
PHP: 5.6
POSTGRES: 9
postgres-php7.0:
image: nextcloudci/php7.0:php7.0-16
commands:
Expand Down Expand Up @@ -746,12 +747,19 @@ matrix:
ENABLE_REDIS: true
- DB: postgres
PHP: 5.6
POSTGRES: 9
ENABLE_REDIS: true
- DB: postgres
PHP: 7.0
POSTGRES: 9
ENABLE_REDIS: true
- DB: postgres
PHP: 7.1
POSTGRES: 9
ENABLE_REDIS: true
- DB: postgres
PHP: 7.1
POSTGRES: 10
ENABLE_REDIS: true
- DB: mysqlmb4
PHP: 5.6
Expand Down Expand Up @@ -833,7 +841,7 @@ services:
when:
matrix:
ENABLE_REDIS_CLUSTER: true
postgres:
postgres-9:
image: postgres:9
environment:
- POSTGRES_USER=oc_autotest
Expand All @@ -843,6 +851,18 @@ services:
when:
matrix:
DB: postgres
POSTGRES: 9
postgres-10:
image: postgres:10
environment:
- POSTGRES_USER=oc_autotest
- POSTGRES_PASSWORD=owncloud
tmpfs:
- /var/lib/postgresql/data
when:
matrix:
DB: postgres
POSTGRES: 10
mysql:
image: mysql:5.7
environment:
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty
Submodule 3rdparty updated 36 files
+5 −0 .gitignore
+7 −1 composer.json
+38 −24 composer.lock
+3 −0 composer/autoload_classmap.php
+3 −0 composer/autoload_static.php
+98 −85 composer/installed.json
+0 −1 doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php
+3 −0 doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php
+29 −11 doctrine/dbal/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
+45 −13 doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
+37 −1 doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
+24 −0 doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php
+49 −0 doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php
+14 −0 doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php
+1 −1 doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php
+2 −2 doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php
+4 −4 doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php
+2 −3 doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php
+15 −3 doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php
+86 −11 doctrine/dbal/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php
+8 −3 doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+37 −0 doctrine/dbal/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php
+4 −0 doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+3 −3 doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+49 −0 doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL100Platform.php
+42 −5 doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+3 −3 doctrine/dbal/lib/Doctrine/DBAL/Portability/Connection.php
+12 −0 doctrine/dbal/lib/Doctrine/DBAL/Portability/Statement.php
+30 −30 doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php
+3 −3 doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php
+70 −2 doctrine/dbal/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php
+1 −1 doctrine/dbal/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
+52 −2 doctrine/dbal/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php
+1 −1 doctrine/dbal/lib/Doctrine/DBAL/Schema/Sequence.php
+2 −2 doctrine/dbal/lib/Doctrine/DBAL/Schema/Table.php
+1 −1 doctrine/dbal/lib/Doctrine/DBAL/Version.php
4 changes: 2 additions & 2 deletions autotest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ function execute_tests {
echo "Postgres is up."
else
if [ ! -z "$DRONE" ] ; then
DATABASEHOST=postgres
DATABASEHOST="postgres-$POSTGRES"
fi
echo "Waiting for Postgres to be available ..."
if ! apps/files_external/tests/env/wait-for-connection $DATABASEHOST 5432 60; then
echo "[ERROR] Waited 60 seconds, no response" >&2
echo "[ERROR] Waited 60 seconds for $DATABASEHOST, no response" >&2
exit 1
fi
echo "Give it 10 additional seconds ..."
Expand Down
1 change: 0 additions & 1 deletion lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,6 @@
'OC\\DB\\Migrator' => $baseDir . '/lib/private/DB/Migrator.php',
'OC\\DB\\MySQLMigrator' => $baseDir . '/lib/private/DB/MySQLMigrator.php',
'OC\\DB\\MySqlTools' => $baseDir . '/lib/private/DB/MySqlTools.php',
'OC\\DB\\OCPostgreSqlPlatform' => $baseDir . '/lib/private/DB/OCPostgreSqlPlatform.php',
'OC\\DB\\OCSqlitePlatform' => $baseDir . '/lib/private/DB/OCSqlitePlatform.php',
'OC\\DB\\OracleConnection' => $baseDir . '/lib/private/DB/OracleConnection.php',
'OC\\DB\\OracleMigrator' => $baseDir . '/lib/private/DB/OracleMigrator.php',
Expand Down
1 change: 0 additions & 1 deletion lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\DB\\Migrator' => __DIR__ . '/../../..' . '/lib/private/DB/Migrator.php',
'OC\\DB\\MySQLMigrator' => __DIR__ . '/../../..' . '/lib/private/DB/MySQLMigrator.php',
'OC\\DB\\MySqlTools' => __DIR__ . '/../../..' . '/lib/private/DB/MySqlTools.php',
'OC\\DB\\OCPostgreSqlPlatform' => __DIR__ . '/../../..' . '/lib/private/DB/OCPostgreSqlPlatform.php',
'OC\\DB\\OCSqlitePlatform' => __DIR__ . '/../../..' . '/lib/private/DB/OCSqlitePlatform.php',
'OC\\DB\\OracleConnection' => __DIR__ . '/../../..' . '/lib/private/DB/OracleConnection.php',
'OC\\DB\\OracleMigrator' => __DIR__ . '/../../..' . '/lib/private/DB/OracleMigrator.php',
Expand Down
3 changes: 0 additions & 3 deletions lib/private/DB/ConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ public function getConnection($type, $additionalConnectionParams) {
unset($additionalConnectionParams['host']);
break;

case 'pgsql':
$additionalConnectionParams['platform'] = new OCPostgreSqlPlatform();
break;
case 'sqlite3':
$journalMode = $additionalConnectionParams['sqlite.journal_mode'];
$additionalConnectionParams['platform'] = new OCSqlitePlatform();
Expand Down
95 changes: 0 additions & 95 deletions lib/private/DB/OCPostgreSqlPlatform.php

This file was deleted.

35 changes: 18 additions & 17 deletions tests/lib/DB/OCPostgreSqlPlatformTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,34 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

namespace Test\DB;

use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\Type;
use OC\DB\OCPostgreSqlPlatform;

/**

/**
* Class OCPostgreSqlPlatformTest
*
* custom OCPostgreSqlPlatform behavior has been upstreamed, test is left to
* ensure behavior stays correct.
*
* @group DB
*
* @package Test\DB
*/

class OCPostgreSqlPlatformTest extends \Test\TestCase {

public function testAlterBigint(){
$platform = new OCPostgreSqlPlatform();
public function testAlterBigint() {
$platform = new PostgreSqlPlatform();
$sourceSchema = new Schema();
$targetSchema = new Schema();

$this->createTableAndColumn($sourceSchema, Type::INTEGER);
$this->createTableAndColumn($targetSchema, Type::BIGINT);

$comparator = new Comparator();
$diff = $comparator->compare($sourceSchema, $targetSchema);
$sqlStatements = $diff->toSql($platform);
Expand All @@ -53,22 +54,22 @@ public function testAlterBigint(){
$sqlStatements,
true
);

$this->assertNotContains(
'ALTER TABLE poor_yorick ALTER id DROP DEFAULT',
$sqlStatements,
true
);
}
protected function createTableAndColumn($schema, $type){

protected function createTableAndColumn($schema, $type) {
$table = $schema->createTable("poor_yorick");
$table->addColumn('id', $type, [
'autoincrement' => true,
'unsigned' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
'notnull' => true,
'length' => 11,
]);
}

}

0 comments on commit 4a63727

Please sign in to comment.