Skip to content
Permalink
Browse files

Fix default value handling of N prefix in SQL server

In the _defalutValue() method, we would get strings like the following:
- 'ASCII'
- N'日本語'
- N'日本語' collate Japanese_Unicode_CI_AI
  • Loading branch information...
chinpei215 committed Oct 10, 2016
1 parent 98c4a6b commit 9963c9f2066be02ff1c2f06cf34cfaca503f61fa
@@ -186,7 +186,7 @@ protected function _defaultValue($default)
}
// Remove quotes
if (preg_match("/^'(.*)'$/", $default, $matches)) {
if (preg_match("/^N?'(.*)'/", $default, $matches)) {
return str_replace("''", "'", $matches[1]);
}
@@ -63,8 +63,8 @@ protected function _createTables($connection)
$table = <<<SQL
CREATE TABLE schema_articles (
id BIGINT PRIMARY KEY,
title VARCHAR(20) COLLATE Japanese_Unicode_CI_AI,
body VARCHAR(1000),
title NVARCHAR(20) COLLATE Japanese_Unicode_CI_AI DEFAULT N'無題' COLLATE Japanese_Unicode_CI_AI,
body NVARCHAR(1000) DEFAULT N'本文なし',
author_id INTEGER NOT NULL,
published BIT DEFAULT 0,
views SMALLINT DEFAULT 0,
@@ -302,8 +302,8 @@ public function testDescribeTable()
'title' => [
'type' => 'string',
'null' => true,
'default' => null,
'length' => 20,
'default' => '無題',
'length' => 40,
'precision' => null,
'comment' => null,
'fixed' => null,
@@ -312,8 +312,8 @@ public function testDescribeTable()
'body' => [
'type' => 'string',
'null' => true,
'default' => null,
'length' => 1000,
'default' => '本文なし',
'length' => 2000,
'precision' => null,
'fixed' => null,
'comment' => null,

0 comments on commit 9963c9f

Please sign in to comment.
You can’t perform that action at this time.