Skip to content

Commit

Permalink
Map binaryuuid into UNIQUEIDENTIFIER
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
markstory committed Oct 19, 2017
1 parent 1ce4ba4 commit 1cb0a77
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
6 changes: 1 addition & 5 deletions src/Database/Schema/SqlserverSchema.php
Expand Up @@ -130,10 +130,6 @@ protected function _convertColumn($col, $length = null, $precision = null, $scal
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];
}
Expand Down Expand Up @@ -339,7 +335,7 @@ public function columnSql(TableSchema $schema, $name)
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',
Expand Down
9 changes: 1 addition & 8 deletions tests/TestCase/Database/Schema/SqlserverSchemaTest.php
Expand Up @@ -221,13 +221,6 @@ public static function convertColumnProvider()
null,
['type' => 'uuid']
],
[
'BINARY',
16,
null,
null,
['type' => 'binaryuuid', 'length' => null]
],
[
'TEXT',
null,
Expand Down Expand Up @@ -541,7 +534,7 @@ public static function columnSqlProvider()
[
'id',
['type' => 'binaryuuid', 'null' => false],
'[id] BINARY(16) NOT NULL'
'[id] UNIQUEIDENTIFIER NOT NULL'
],
[
'role',
Expand Down

0 comments on commit 1cb0a77

Please sign in to comment.