Skip to content

Commit 4fca80f

Browse files
committed
Fixing SQLServer table level comments
1 parent e4478a0 commit 4fca80f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,11 +1693,22 @@ private function generateIdentifierName($identifier)
16931693
return strtoupper(dechex(crc32($identifier->getName())));
16941694
}
16951695

1696+
public function getCommentOnTableSQL(string $tableName, ?string $comment) : string
1697+
{
1698+
return sprintf(
1699+
'EXEC sys.sp_addextendedproperty @name=N\'MS_Description\',
1700+
@value=N%s , @level0type=N\'SCHEMA\',@level0name=N\'dbo\',
1701+
@level1type=N\'TABLE\',@level1name=N%s',
1702+
$this->quoteStringLiteral((string) $comment),
1703+
$this->quoteStringLiteral($tableName)
1704+
);
1705+
}
1706+
16961707
public function getListTableMetadataSQL(string $table) : string
16971708
{
16981709
return sprintf(
16991710
<<<'SQL'
1700-
SELECT td.value AS [table_comment],
1711+
SELECT td.value AS [table_comment]
17011712
FROM sysobjects t
17021713
INNER JOIN sysusers u
17031714
ON u.uid = t.uid
@@ -1706,7 +1717,7 @@ public function getListTableMetadataSQL(string $table) : string
17061717
AND td.minor_id = 0
17071718
AND td.name = 'MS_Description'
17081719
WHERE t.type = %s
1709-
ORDER BY t.name, c.colorder
1720+
ORDER BY t.name
17101721
SQL
17111722
,
17121723
$this->quoteStringLiteral($table)

0 commit comments

Comments
 (0)