diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2023-03-02 12:10:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-02 12:10:19 +0100 |
commit | 289fadfd504f0a36836e8c0a082a51e16d3b8da2 (patch) | |
tree | 5bdf8c16668c83881e5c85037bb0481b8437c52f | |
parent | e08fa782249c201baf042c8cdf2362fc2300f85f (diff) | |
parent | 1785a80754f57b9f98285a0b98e19af8f2afbdd6 (diff) | |
download | nextcloud-server-289fadfd504f0a36836e8c0a082a51e16d3b8da2.tar.gz nextcloud-server-289fadfd504f0a36836e8c0a082a51e16d3b8da2.zip |
Merge pull request #36803 from nextcloud/fix/sqlite-comments
[db]: Remove not supported column comments for SQLite
-rw-r--r-- | lib/private/DB/SQLiteMigrator.php | 6 | ||||
-rw-r--r-- | tests/lib/DB/MigratorTest.php | 24 |
2 files changed, 29 insertions, 1 deletions
diff --git a/lib/private/DB/SQLiteMigrator.php b/lib/private/DB/SQLiteMigrator.php index 2be3591afdc..cbb39070a48 100644 --- a/lib/private/DB/SQLiteMigrator.php +++ b/lib/private/DB/SQLiteMigrator.php @@ -39,9 +39,13 @@ class SQLiteMigrator extends Migrator { $platform->registerDoctrineTypeMapping('smallint unsigned', 'integer'); $platform->registerDoctrineTypeMapping('varchar ', 'string'); - // with sqlite autoincrement columns is of type integer foreach ($targetSchema->getTables() as $table) { foreach ($table->getColumns() as $column) { + // column comments are not supported on SQLite + if ($column->getComment() !== null) { + $column->setComment(null); + } + // with sqlite autoincrement columns is of type integer if ($column->getType() instanceof BigIntType && $column->getAutoincrement()) { $column->setType(Type::getType('integer')); } diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php index af56730f9f6..6a2b113a796 100644 --- a/tests/lib/DB/MigratorTest.php +++ b/tests/lib/DB/MigratorTest.php @@ -237,6 +237,30 @@ class MigratorTest extends \Test\TestCase { $this->addToAssertionCount(1); } + /** + * Test for nextcloud/server#36803 + */ + public function testColumnCommentsInUpdate() { + $startSchema = new Schema([], [], $this->getSchemaConfig()); + $table = $startSchema->createTable($this->tableName); + $table->addColumn('id', 'integer', ['autoincrement' => true, 'comment' => 'foo']); + $table->setPrimaryKey(['id']); + + $endSchema = new Schema([], [], $this->getSchemaConfig()); + $table = $endSchema->createTable($this->tableName); + $table->addColumn('id', 'integer', ['autoincrement' => true, 'comment' => 'foo']); + // Assert adding comments on existing tables work (or at least does not throw) + $table->addColumn('time', 'integer', ['comment' => 'unix-timestamp', 'notnull' => false]); + $table->setPrimaryKey(['id']); + + $migrator = $this->getMigrator(); + $migrator->migrate($startSchema); + + $migrator->migrate($endSchema); + + $this->addToAssertionCount(1); + } + public function testAddingForeignKey() { $startSchema = new Schema([], [], $this->getSchemaConfig()); $table = $startSchema->createTable($this->tableName); |