Commit 0bb14561 authored by Juozas Kaziukenas's avatar Juozas Kaziukenas

Changed string datatypes to unicode

parent df0f0016
...@@ -485,8 +485,8 @@ DROP DATABASE ' . $name . ';'; ...@@ -485,8 +485,8 @@ DROP DATABASE ' . $name . ';';
$length = ($field['length'] <= $this->getVarcharMaxLength()) ? $field['length'] : false; $length = ($field['length'] <= $this->getVarcharMaxLength()) ? $field['length'] : false;
$fixed = (isset($field['fixed'])) ? $field['fixed'] : false; $fixed = (isset($field['fixed'])) ? $field['fixed'] : false;
return $fixed ? ($length ? 'CHAR(' . $length . ')' : 'CHAR(255)') return $fixed ? ($length ? 'NCHAR(' . $length . ')' : 'CHAR(255)')
: ($length ? 'VARCHAR(' . $length . ')' : 'TEXT'); : ($length ? 'NVARCHAR(' . $length . ')' : 'NTEXT');
} }
/** @override */ /** @override */
......
...@@ -76,6 +76,14 @@ class MsSqlSchemaManager extends AbstractSchemaManager ...@@ -76,6 +76,14 @@ class MsSqlSchemaManager extends AbstractSchemaManager
$fixed = false; $fixed = false;
break; break;
} }
switch ($dbType) {
case 'nchar':
case 'nvarchar':
case 'ntext':
// Unicode data requires 2 bytes per character
$length = $length / 2;
break;
}
$options = array( $options = array(
'length' => ($length == 0 || !in_array($type, array('text', 'string'))) ? null : $length, 'length' => ($length == 0 || !in_array($type, array('text', 'string'))) ? null : $length,
......
...@@ -16,13 +16,13 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase ...@@ -16,13 +16,13 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase
public function getGenerateTableSql() public function getGenerateTableSql()
{ {
return 'CREATE TABLE test (id INT IDENTITY NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))'; return 'CREATE TABLE test (id INT IDENTITY NOT NULL, test NVARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))';
} }
public function getGenerateTableWithMultiColumnUniqueIndexSql() public function getGenerateTableWithMultiColumnUniqueIndexSql()
{ {
return array( return array(
'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL)', 'CREATE TABLE test (foo NVARCHAR(255) DEFAULT NULL, bar NVARCHAR(255) DEFAULT NULL)',
'CREATE UNIQUE INDEX test_foo_bar_uniq ON test (foo, bar)' 'CREATE UNIQUE INDEX test_foo_bar_uniq ON test (foo, bar)'
); );
} }
...@@ -33,7 +33,7 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase ...@@ -33,7 +33,7 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase
'ALTER TABLE mytable RENAME TO userlist', 'ALTER TABLE mytable RENAME TO userlist',
'ALTER TABLE mytable ADD quota INT DEFAULT NULL', 'ALTER TABLE mytable ADD quota INT DEFAULT NULL',
'ALTER TABLE mytable DROP COLUMN foo', 'ALTER TABLE mytable DROP COLUMN foo',
'ALTER TABLE mytable CHANGE bar baz VARCHAR(255) DEFAULT \'def\' NOT NULL', 'ALTER TABLE mytable CHANGE bar baz NVARCHAR(255) DEFAULT \'def\' NOT NULL',
); );
} }
...@@ -99,17 +99,17 @@ DDB; ...@@ -99,17 +99,17 @@ DDB;
public function testGeneratesTypeDeclarationsForStrings() public function testGeneratesTypeDeclarationsForStrings()
{ {
$this->assertEquals( $this->assertEquals(
'CHAR(10)', 'NCHAR(10)',
$this->_platform->getVarcharTypeDeclarationSQL( $this->_platform->getVarcharTypeDeclarationSQL(
array('length' => 10, 'fixed' => true) array('length' => 10, 'fixed' => true)
)); ));
$this->assertEquals( $this->assertEquals(
'VARCHAR(50)', 'NVARCHAR(50)',
$this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)), $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)),
'Variable string declaration is not correct' 'Variable string declaration is not correct'
); );
$this->assertEquals( $this->assertEquals(
'TEXT', 'NTEXT',
$this->_platform->getVarcharTypeDeclarationSQL(array()), $this->_platform->getVarcharTypeDeclarationSQL(array()),
'Long string declaration is not correct' 'Long string declaration is not correct'
); );
......
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