Browse Source

Map binaryuuid into UNIQUEIDENTIFIER

Like postgres, SQLServer will take binary data in its UNIQUEIDENTIFIER
data and correctly preserve it as a UUID under the hood. This means
there is no reflection arm for binary uuids as they aren't a different
datatype in sqlserver.
Mark Story 8 years ago
parent
commit
1cb0a77782

+ 1 - 5
src/Database/Schema/SqlserverSchema.php

@@ -130,10 +130,6 @@ class SqlserverSchema extends BaseSchema
             return ['type' => TableSchema::TYPE_TEXT, 'length' => null];
         }
 
-        if ($col === 'binary' && (int)$length === 16) {
-            return ['type' => TableSchema::TYPE_BINARY_UUID, 'length' => null];
-        }
-
         if ($col === 'image' || strpos($col, 'binary')) {
             return ['type' => TableSchema::TYPE_BINARY, 'length' => null];
         }
@@ -339,7 +335,7 @@ class SqlserverSchema extends BaseSchema
             TableSchema::TYPE_SMALLINTEGER => ' SMALLINT',
             TableSchema::TYPE_INTEGER => ' INTEGER',
             TableSchema::TYPE_BIGINTEGER => ' BIGINT',
-            TableSchema::TYPE_BINARY_UUID => ' BINARY(16)',
+            TableSchema::TYPE_BINARY_UUID => ' UNIQUEIDENTIFIER',
             TableSchema::TYPE_BOOLEAN => ' BIT',
             TableSchema::TYPE_FLOAT => ' FLOAT',
             TableSchema::TYPE_DECIMAL => ' DECIMAL',

+ 1 - 8
tests/TestCase/Database/Schema/SqlserverSchemaTest.php

@@ -222,13 +222,6 @@ SQL;
                 ['type' => 'uuid']
             ],
             [
-                'BINARY',
-                16,
-                null,
-                null,
-                ['type' => 'binaryuuid', 'length' => null]
-            ],
-            [
                 'TEXT',
                 null,
                 null,
@@ -541,7 +534,7 @@ SQL;
             [
                 'id',
                 ['type' => 'binaryuuid', 'null' => false],
-                '[id] BINARY(16) NOT NULL'
+                '[id] UNIQUEIDENTIFIER NOT NULL'
             ],
             [
                 'role',