Skip to content

Commit

Permalink
Fix default value handling of N prefix in SQL server
Browse files Browse the repository at this point in the history
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 9963c9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Database/Schema/SqlserverSchema.php
Expand Up @@ -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]);
}

Expand Down
12 changes: 6 additions & 6 deletions tests/TestCase/Database/Schema/SqlserverSchemaTest.php
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 9963c9f

Please sign in to comment.