Skip to content

Commit

Permalink
Fix MSSQL CLOB column type to support Unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Nov 14, 2021
1 parent 0ae1aa5 commit 590e8bd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function supportsLimitOffset()
*/
public function getClobTypeDeclarationSQL(array $column)
{
return 'VARCHAR(MAX)';
return 'NVARCHAR(MAX)';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ public function getBinaryMaxLength()
*/
public function getClobTypeDeclarationSQL(array $column)
{
return 'VARCHAR(MAX)';
return 'NVARCHAR(MAX)';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ public function testGeneratesTypeDeclarationsForStrings(): void
'NVARCHAR(255)',
$this->platform->getVarcharTypeDeclarationSQL([])
);
self::assertSame('VARCHAR(MAX)', $this->platform->getClobTypeDeclarationSQL([]));
self::assertSame('NVARCHAR(MAX)', $this->platform->getClobTypeDeclarationSQL([]));
self::assertSame(
'VARCHAR(MAX)',
'NVARCHAR(MAX)',
$this->platform->getClobTypeDeclarationSQL(['length' => 5, 'fixed' => true])
);
}
Expand Down Expand Up @@ -741,7 +741,7 @@ public function getAlterTableColumnCommentsSQL(): array
public function getCreateTableColumnTypeCommentsSQL(): array
{
return [
'CREATE TABLE test (id INT NOT NULL, data VARCHAR(MAX) NOT NULL, PRIMARY KEY (id))',
'CREATE TABLE test (id INT NOT NULL, data NVARCHAR(MAX) NOT NULL, PRIMARY KEY (id))',
"EXEC sp_addextendedproperty N'MS_Description', N'(DC2Type:array)', "
. "N'SCHEMA', 'dbo', N'TABLE', 'test', N'COLUMN', data",
];
Expand Down Expand Up @@ -780,8 +780,8 @@ public function testGeneratesCreateTableSQLWithColumnComments(): void
. 'comment INT NOT NULL, '
. '[comment_quoted] INT NOT NULL, '
. '[create] INT NOT NULL, '
. 'commented_type VARCHAR(MAX) NOT NULL, '
. 'commented_type_with_comment VARCHAR(MAX) NOT NULL, '
. 'commented_type NVARCHAR(MAX) NOT NULL, '
. 'commented_type_with_comment NVARCHAR(MAX) NOT NULL, '
. 'comment_with_string_literal_char NVARCHAR(255) NOT NULL, '
. 'PRIMARY KEY (id))',
"EXEC sp_addextendedproperty N'MS_Description', "
Expand Down Expand Up @@ -988,14 +988,14 @@ public function testGeneratesAlterTableSQLWithColumnComments(): void
'ALTER TABLE mytable ADD added_comment INT NOT NULL',
'ALTER TABLE mytable ADD [added_comment_quoted] INT NOT NULL',
'ALTER TABLE mytable ADD [select] INT NOT NULL',
'ALTER TABLE mytable ADD added_commented_type VARCHAR(MAX) NOT NULL',
'ALTER TABLE mytable ADD added_commented_type_with_comment VARCHAR(MAX) NOT NULL',
'ALTER TABLE mytable ADD added_commented_type NVARCHAR(MAX) NOT NULL',
'ALTER TABLE mytable ADD added_commented_type_with_comment NVARCHAR(MAX) NOT NULL',
'ALTER TABLE mytable ADD added_comment_with_string_literal_char NVARCHAR(255) NOT NULL',
'ALTER TABLE mytable DROP COLUMN comment_integer_0',
'ALTER TABLE mytable ALTER COLUMN comment_null NVARCHAR(255) NOT NULL',
'ALTER TABLE mytable ALTER COLUMN comment_empty_string VARCHAR(MAX) NOT NULL',
'ALTER TABLE mytable ALTER COLUMN [comment_quoted] VARCHAR(MAX) NOT NULL',
'ALTER TABLE mytable ALTER COLUMN [create] VARCHAR(MAX) NOT NULL',
'ALTER TABLE mytable ALTER COLUMN comment_empty_string NVARCHAR(MAX) NOT NULL',
'ALTER TABLE mytable ALTER COLUMN [comment_quoted] NVARCHAR(MAX) NOT NULL',
'ALTER TABLE mytable ALTER COLUMN [create] NVARCHAR(MAX) NOT NULL',
'ALTER TABLE mytable ALTER COLUMN commented_type INT NOT NULL',

// Added columns.
Expand Down

0 comments on commit 590e8bd

Please sign in to comment.