Repository metrics
- Stars
- (9,693 個のスター)
- PR merge metrics
- (平均マージ 12h 52m) (30d で 46 merged PRs)
説明
Bug Report
| Q | A |
|---|---|
| Version | 3.3.8 |
Summary
Nextcloud got a report that column comments on sqlite leads to an sql error like: General error: 1 incomplete input12
The code to add the column.
$table->addColumn('foo', Types::INTEGER, [
'notnull' => false,
'default' => 0,
'comment' => 'unix-timestamp',
]);
It works to run all migrations on a clean database. It breaks when the migration with the column comment is executed alone.
The generated alter table query is:
ALTER TABLE oc_forms_v2_forms ADD COLUMN last_updated INTEGER DEFAULT 0 --unix-timestamp
Comments with -- are not supported (or broken) according to: https://sqlite.org/forum/forumpost/4bb7806a96e863f0
A possible solution could be to drop comments for alter table statments on sqlite.
Index: src/Platforms/SqlitePlatform.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/Platforms/SqlitePlatform.php b/src/Platforms/SqlitePlatform.php
--- a/src/Platforms/SqlitePlatform.php (revision 3fc4ea3565d54ff1cc944e5c4e01cc9dc2920df2)
+++ b/src/Platforms/SqlitePlatform.php (date 1677275353199)
@@ -1263,6 +1263,9 @@
$definition['length'] ??= 255;
}
+ // SQLite does not support sql schema comments in alter table statements
+ unset($definition['comment']);
+
$sql[] = 'ALTER TABLE ' . $table->getQuotedName($this) . ' ADD COLUMN '
. $this->getColumnDeclarationSQL($definition['name'], $definition);
}
Migrating from -- to /* */ should also work, but it seems complicated to make dbal work with the sql style comments and c style comments.
Current behaviour
The generated sql query results in an error
How to reproduce
- Use sqlite
- Create a table
- Add a column with a comment
- :boom:
Expected behaviour
No sql error ;)