Fix parsing column comments on SQLite

parent 86e563a3
......@@ -496,7 +496,7 @@ CREATE\sTABLE # Match "CREATE TABLE"
private function parseColumnCommentFromSQL(string $column, string $sql) : ?string
{
$pattern = '{[\s(,](?:\W' . preg_quote($this->_platform->quoteSingleIdentifier($column)) . '\W|\W' . preg_quote($column)
. '\W)(?:\(.*?\)|[^,(])*?,?((?:(?!\n))(?:\s*--[^\n]*\n?)+)}i';
. '\W)(?:\([^)]*?\)|[^,(])*?,?((?:(?!\n))(?:\s*--[^\n]*\n?)+)}i';
if (preg_match($pattern, $sql, $match) !== 1) {
return null;
......
......@@ -278,4 +278,19 @@ SQL;
// with an empty table, non autoincrement rowid is always 1
$this->assertEquals(1, $lastUsedIdAfterDelete);
}
public function testOnlyOwnCommentIsParsed() : void
{
$table = new Table('own_column_comment');
$table->addColumn('col1', 'string', ['length' => 16]);
$table->addColumn('col2', 'string', ['length' => 16, 'comment' => 'Column #2']);
$table->addColumn('col3', 'string', ['length' => 16]);
$sm = $this->connection->getSchemaManager();
$sm->createTable($table);
$this->assertNull($sm->listTableDetails('own_column_comment')
->getColumn('col1')
->getComment());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment