[DBAL-1233] TEXT type in MSSQL should be NVARCHAR(MAX) not VARCHAR(MAX) Created: 19/May/15  Updated: 26/Jun/15  Resolved: 26/Jun/15

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms, Schema Managers
Affects Version/s: None
Fix Version/s: 2.5.2
Security Level: All

Type: Bug Priority: Major
Reporter: Javad Rahimi Assignee: Benjamin Eberlei
Resolution: Incomplete Votes: 0
Labels: mssql, nvarchar(max), schema, text, validator


If a field type is defined as "TEXT" by generating the schema in MSSQL Server it generates a field type as "VARCHAR(MAX)". There will be no problem unless some UTF8 characters be inserted to DB; they all will be saved as "?????". If the field type be changed to "NVARCHAR(MAX)" there will be no problem and UTF8 characters will saved properly.
In this case I changed the DBAL core for SQL server as:

public function getClobTypeDeclartionSQL(array $field)
     return 'NVARCHAR(MAX)';

This fixed the main issue but after I generate the schema, whenever I validate my schema, it returns false on DB level.
Could anybody help me in this case? Is there any other fixes I need to do?

Appreciate it in advance.

Comment by Javad Rahimi [ 26/Jun/15 ]

A temporary solution might be to change the function as:

// Used NTEXT instead
public function getClobTypeDeclartionSQL(array $field)
     return 'NTEXT';

It will fix the partially but as you know NTEXT will omit lots of functionalities on different SELECT queries and it's going to be deprecated by Microsoft.

I hope someone could find a better solution for this issue.

Generated at Wed Jul 01 12:48:26 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.