Unverified Commit 6c789b30 authored by Grégoire Paris's avatar Grégoire Paris Committed by GitHub

Merge pull request #3939 from morozov/issues/3937

Fix parsing column comments on SQLite
parents 86e563a3 a5a09a10
...@@ -496,7 +496,7 @@ CREATE\sTABLE # Match "CREATE TABLE" ...@@ -496,7 +496,7 @@ CREATE\sTABLE # Match "CREATE TABLE"
private function parseColumnCommentFromSQL(string $column, string $sql) : ?string private function parseColumnCommentFromSQL(string $column, string $sql) : ?string
{ {
$pattern = '{[\s(,](?:\W' . preg_quote($this->_platform->quoteSingleIdentifier($column)) . '\W|\W' . preg_quote($column) $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) { if (preg_match($pattern, $sql, $match) !== 1) {
return null; return null;
......
...@@ -278,4 +278,19 @@ SQL; ...@@ -278,4 +278,19 @@ SQL;
// with an empty table, non autoincrement rowid is always 1 // with an empty table, non autoincrement rowid is always 1
$this->assertEquals(1, $lastUsedIdAfterDelete); $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