ソースを参照

Merge pull request #11303 from cakephp/issue-11296

Cast length/precision/scale to integers in SQLServer
Mark Story 8 年 前
コミット
6b2fed57f6

+ 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];
         }

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

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