Browse Source

Shim binary16 support for migration based testing (#17421)

* Use UUID_BLOB for binary16
Mark Scherer 2 years ago
parent
commit
91fd995d88

+ 4 - 4
src/Database/Schema/SqliteSchemaDialect.php

@@ -49,7 +49,7 @@ class SqliteSchemaDialect extends SchemaDialect
         }
 
         preg_match('/(unsigned)?\s*([a-z]+)(?:\(([0-9,]+)\))?/i', $column, $matches);
-        if (empty($matches)) {
+        if (!$matches) {
             throw new DatabaseException(sprintf('Unable to parse column type from `%s`', $column));
         }
 
@@ -110,6 +110,9 @@ class SqliteSchemaDialect extends SchemaDialect
             return ['type' => TableSchemaInterface::TYPE_BOOLEAN, 'length' => null];
         }
 
+        if (($col === 'binary' && $length === 16) || strtolower($column) === 'uuid_blob') {
+            return ['type' => TableSchemaInterface::TYPE_BINARY_UUID, 'length' => null];
+        }
         if (($col === 'char' && $length === 36) || $col === 'uuid') {
             return ['type' => TableSchemaInterface::TYPE_UUID, 'length' => null];
         }
@@ -120,9 +123,6 @@ class SqliteSchemaDialect extends SchemaDialect
             return ['type' => TableSchemaInterface::TYPE_STRING, 'length' => $length];
         }
 
-        if ($col === 'binary' && $length === 16) {
-            return ['type' => TableSchemaInterface::TYPE_BINARY_UUID, 'length' => null];
-        }
         if (in_array($col, ['blob', 'clob', 'binary', 'varbinary'])) {
             return ['type' => TableSchemaInterface::TYPE_BINARY, 'length' => $length];
         }

+ 4 - 0
tests/TestCase/Database/Schema/SqliteSchemaTest.php

@@ -153,6 +153,10 @@ class SqliteSchemaTest extends TestCase
                 'UUID_TEXT',
                 ['type' => 'uuid', 'length' => null],
             ],
+            [
+                'UUID_BLOB',
+                ['type' => 'binaryuuid', 'length' => null],
+            ],
         ];
     }