Browse Source

Cast length/precision/scale to integers in SQLServer

Schema reflection would leave length as a string when it should be an
integer. The same was true for precision and scale.

Refs #11296
Mark Story 8 years ago
parent
commit
8bc332debd

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

@@ -81,6 +81,10 @@ class SqlserverSchema extends BaseSchema
     protected function _convertColumn($col, $length = null, $precision = null, $scale = null)
     {
         $col = strtolower($col);
+        $length = (int)$length;
+        $precision = (int)$precision;
+        $scale = (int)$scale;
+
         if (in_array($col, ['date', 'time'])) {
             return ['type' => $col, 'length' => null];
         }

+ 1 - 1
tests/TestCase/Database/Schema/SqlserverSchemaTest.php

@@ -408,7 +408,7 @@ SQL;
         ];
         $this->assertEquals(['id'], $result->primaryKey());
         foreach ($expected as $field => $definition) {
-            $this->assertEquals($definition, $result->column($field), 'Failed to match field ' . $field);
+            $this->assertSame($definition, $result->column($field), 'Failed to match field ' . $field);
         }
     }