Browse Source

Add binaryuuid reflection/generation to sqlserver.

Mark Story 8 years ago
parent
commit
6e3777b42a

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

@@ -130,6 +130,10 @@ class SqlserverSchema extends BaseSchema
             return ['type' => TableSchema::TYPE_TEXT, 'length' => null];
         }
 
+        if ($col === 'binary' && $length === 16) {
+            return ['type' => TableSchema::TYPE_BINARY_UUID, 'length' => null];
+        }
+
         if ($col === 'image' || strpos($col, 'binary')) {
             return ['type' => TableSchema::TYPE_BINARY, 'length' => null];
         }
@@ -335,6 +339,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_BOOLEAN => ' BIT',
             TableSchema::TYPE_FLOAT => ' FLOAT',
             TableSchema::TYPE_DECIMAL => ' DECIMAL',

+ 12 - 0
tests/TestCase/Database/Schema/SqlserverSchemaTest.php

@@ -222,6 +222,13 @@ SQL;
                 ['type' => 'uuid']
             ],
             [
+                'BINARY',
+                16,
+                null,
+                null,
+                ['type' => 'binaryuuid', 'length' => null]
+            ],
+            [
                 'TEXT',
                 null,
                 null,
@@ -532,6 +539,11 @@ SQL;
                 '[id] UNIQUEIDENTIFIER NOT NULL'
             ],
             [
+                'id',
+                ['type' => 'binaryuuid', 'null' => false],
+                '[id] BINARY(16) NOT NULL'
+            ],
+            [
                 'role',
                 ['type' => 'string', 'length' => 10, 'null' => false, 'default' => 'admin'],
                 "[role] NVARCHAR(10) NOT NULL DEFAULT 'admin'"