Browse Source

Merge pull request #13715 from cakephp/issue-13714

Fix Sqlserver reflection of VARBINARY(MAX)
Mark Story 6 years ago
parent
commit
ca225fd205

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

@@ -138,6 +138,11 @@ class SqlserverSchema extends BaseSchema
         }
 
         if ($col === 'image' || strpos($col, 'binary') !== false) {
+            // -1 is the value for MAX which we treat as a 'long' binary
+            if ($length == -1) {
+                $length = TableSchema::LENGTH_LONG;
+            }
+
             return ['type' => TableSchema::TYPE_BINARY, 'length' => $length];
         }
 

+ 7 - 0
tests/TestCase/Database/Schema/SqlserverSchemaTest.php

@@ -265,6 +265,13 @@ SQL;
                 null,
                 ['type' => 'binary', 'length' => 30]
             ],
+            [
+                'VARBINARY',
+                -1,
+                null,
+                null,
+                ['type' => 'binary', 'length' => TableSchema::LENGTH_LONG]
+            ],
         ];
     }