From 123c5c8fb69e4d0788df6a943dc23d71475b7d96 Mon Sep 17 00:00:00 2001 From: Dmitriy Romanov Date: Tue, 2 Oct 2018 20:33:50 +0300 Subject: [PATCH] Fixed detection of "binary" column. SqlserverSchema now returns lengths of binary fields. --- src/Database/Schema/SqlserverSchema.php | 4 ++-- .../Database/Schema/SqlserverSchemaTest.php | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Database/Schema/SqlserverSchema.php b/src/Database/Schema/SqlserverSchema.php index b4efac8a04e..74bfc91e85b 100644 --- a/src/Database/Schema/SqlserverSchema.php +++ b/src/Database/Schema/SqlserverSchema.php @@ -138,8 +138,8 @@ protected function _convertColumn($col, $length = null, $precision = null, $scal return ['type' => TableSchema::TYPE_TEXT, 'length' => null]; } - if ($col === 'image' || strpos($col, 'binary')) { - return ['type' => TableSchema::TYPE_BINARY, 'length' => null]; + if ($col === 'image' || strpos($col, 'binary') !== false) { + return ['type' => TableSchema::TYPE_BINARY, 'length' => $length]; } if ($col === 'uniqueidentifier') { diff --git a/tests/TestCase/Database/Schema/SqlserverSchemaTest.php b/tests/TestCase/Database/Schema/SqlserverSchemaTest.php index 2be306181ef..d145896fb5c 100644 --- a/tests/TestCase/Database/Schema/SqlserverSchemaTest.php +++ b/tests/TestCase/Database/Schema/SqlserverSchemaTest.php @@ -244,6 +244,27 @@ public static function convertColumnProvider() null, ['type' => 'text', 'length' => null] ], + [ + 'IMAGE', + 10, + null, + null, + ['type' => 'binary', 'length' => 10] + ], + [ + 'BINARY', + 20, + null, + null, + ['type' => 'binary', 'length' => 20] + ], + [ + 'VARBINARY', + 30, + null, + null, + ['type' => 'binary', 'length' => 30] + ], ]; }