Skip to content

Commit

Permalink
Add binaryuuid reflection/generation to sqlserver.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Oct 15, 2017
1 parent 58e26c0 commit 6e3777b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Database/Schema/SqlserverSchema.php
Expand Up @@ -130,6 +130,10 @@ protected function _convertColumn($col, $length = null, $precision = null, $scal
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];
}
Expand Down Expand Up @@ -335,6 +339,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_BOOLEAN => ' BIT',
TableSchema::TYPE_FLOAT => ' FLOAT',
TableSchema::TYPE_DECIMAL => ' DECIMAL',
Expand Down
12 changes: 12 additions & 0 deletions tests/TestCase/Database/Schema/SqlserverSchemaTest.php
Expand Up @@ -221,6 +221,13 @@ public static function convertColumnProvider()
null,
['type' => 'uuid']
],
[
'BINARY',
16,
null,
null,
['type' => 'binaryuuid', 'length' => null]
],
[
'TEXT',
null,
Expand Down Expand Up @@ -531,6 +538,11 @@ public static function columnSqlProvider()
['type' => 'uuid', 'null' => false],
'[id] UNIQUEIDENTIFIER NOT NULL'
],
[
'id',
['type' => 'binaryuuid', 'null' => false],
'[id] BINARY(16) NOT NULL'
],
[
'role',
['type' => 'string', 'length' => 10, 'null' => false, 'default' => 'admin'],
Expand Down

0 comments on commit 6e3777b

Please sign in to comment.