Skip to content

Commit

Permalink
Cast length/precision/scale to integers in SQLServer
Browse files Browse the repository at this point in the history
Schema reflection would leave length as a string when it should be an
integer. The same was true for precision and scale.

Refs #11296
  • Loading branch information
markstory committed Oct 8, 2017
1 parent 8827866 commit 8bc332d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Database/Schema/SqlserverSchema.php
Expand Up @@ -81,6 +81,10 @@ public function describeColumnSql($tableName, $config)
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];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Database/Schema/SqlserverSchemaTest.php
Expand Up @@ -408,7 +408,7 @@ public function testDescribeTable()
];
$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);
}
}

Expand Down

0 comments on commit 8bc332d

Please sign in to comment.