ソースを参照

Adding support for detecting JSON columns in mysql

Jose Lorenzo Rodriguez 10 年 前
コミット
46c3fca9a8

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

@@ -137,6 +137,11 @@ class MysqlSchema extends BaseSchema
                 'unsigned' => $unsigned
             ];
         }
+
+        if (strpos($col, 'json') !== false) {
+            return ['type' => 'json', 'length' => null];
+        }
+
         return ['type' => 'text', 'length' => null];
     }
 

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

@@ -146,6 +146,10 @@ class MysqlSchemaTest extends TestCase
                 'DOUBLE(10,4) UNSIGNED',
                 ['type' => 'float', 'length' => 10, 'precision' => 4, 'unsigned' => true]
             ],
+            [
+                'JSON',
+                ['type' => 'json', 'length' => null]
+            ],
         ];
     }