Browse Source

Add binaryuuid support for postgres.

Postgres UUIDs are _already_ binary compatible. In postgres binaryuuid
and standard uuid map to the same SQL data type. Postgres does not
support lengths on its BYTEA field so UUID is our best option here.
Mark Story 8 years ago
parent
commit
baed1d8b20

+ 1 - 0
src/Database/Schema/PostgresSchema.php

@@ -354,6 +354,7 @@ class PostgresSchema extends BaseSchema
         $typeMap = [
             TableSchema::TYPE_TINYINTEGER => ' SMALLINT',
             TableSchema::TYPE_SMALLINTEGER => ' SMALLINT',
+            TableSchema::TYPE_BINARY_UUID => ' UUID',
             TableSchema::TYPE_BINARY => ' BYTEA',
             TableSchema::TYPE_BOOLEAN => ' BOOLEAN',
             TableSchema::TYPE_FLOAT => ' FLOAT',

+ 5 - 0
tests/TestCase/Database/Schema/PostgresSchemaTest.php

@@ -665,6 +665,11 @@ SQL;
                 '"id" UUID NOT NULL'
             ],
             [
+                'id',
+                ['type' => 'binaryuuid', 'length' => null, 'null' => false],
+                '"id" UUID NOT NULL'
+            ],
+            [
                 'role',
                 ['type' => 'string', 'length' => 10, 'null' => false, 'default' => 'admin'],
                 '"role" VARCHAR(10) NOT NULL DEFAULT \'admin\''