diff options
author | Joas Schilling <coding@schilljs.com> | 2017-09-29 11:07:50 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-09-29 11:10:57 +0200 |
commit | a3bdb318e9f552f342de401d0aff24384a80fcd8 (patch) | |
tree | 915112882a6f92b736b3cebe3d3840404c72bdd9 /tests/lib/DB | |
parent | 155d451cf82b0feb1c68f9d83877645c5e8a8112 (diff) | |
download | nextcloud-server-a3bdb318e9f552f342de401d0aff24384a80fcd8.tar.gz nextcloud-server-a3bdb318e9f552f342de401d0aff24384a80fcd8.zip |
Fix bigint handling on postgres
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib/DB')
-rw-r--r-- | tests/lib/DB/OCPostgreSqlPlatformTest.php | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/tests/lib/DB/OCPostgreSqlPlatformTest.php b/tests/lib/DB/OCPostgreSqlPlatformTest.php new file mode 100644 index 00000000000..56fab621cfc --- /dev/null +++ b/tests/lib/DB/OCPostgreSqlPlatformTest.php @@ -0,0 +1,74 @@ +<?php +/** + * @author Victor Dubiniuk <dubiniuk@owncloud.com> + * + * @copyright Copyright (c) 2017, ownCloud GmbH + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +namespace Test\DB; + +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 + * + * @group DB + * + * @package Test\DB + */ + +class OCPostgreSqlPlatformTest extends \Test\TestCase { + + public function testAlterBigint(){ + $platform = new OCPostgreSqlPlatform(); + $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); + $this->assertContains( + 'ALTER TABLE poor_yorick ALTER id TYPE BIGINT', + $sqlStatements, + true + ); + + $this->assertNotContains( + 'ALTER TABLE poor_yorick ALTER id DROP DEFAULT', + $sqlStatements, + true + ); + } + + protected function createTableAndColumn($schema, $type){ + $table = $schema->createTable("poor_yorick"); + $table->addColumn('id', $type, [ + 'autoincrement' => true, + 'unsigned' => true, + 'notnull' => true, + 'length' => 11, + ]); + } + +} |