Commit 83f83ca8 authored by Jose M. Alonso M's avatar Jose M. Alonso M

Fix quoted integers as default value.

parent 1c9c24a7
......@@ -2241,7 +2241,7 @@ abstract class AbstractPlatform
if (isset($field['default'])) {
$default = " DEFAULT '".$field['default']."'";
if (isset($field['type'])) {
if (in_array((string) $field['type'], array("Integer", "BigInteger", "SmallInteger"))) {
if (in_array((string) $field['type'], array("Integer", "BigInt", "SmallInt"))) {
$default = " DEFAULT ".$field['default'];
} elseif (in_array((string) $field['type'], array('DateTime', 'DateTimeTz')) && $field['default'] == $this->getCurrentTimestampSQL()) {
$default = " DEFAULT ".$this->getCurrentTimestampSQL();
......
......@@ -1454,7 +1454,7 @@ class SQLServerPlatform extends AbstractPlatform
return " DEFAULT '" . $field['default'] . "'";
}
if (in_array((string) $field['type'], array('Integer', 'BigInteger', 'SmallInteger'))) {
if (in_array((string) $field['type'], array('Integer', 'BigInt', 'SmallInt'))) {
return " DEFAULT " . $field['default'];
}
......
......@@ -466,6 +466,23 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
}
}
public function testGetDefaultValueDeclarationSQLForIntegerTypes()
{
foreach(array('bigint', 'integer', 'smallint') as $type) {
$field = array(
'type' => Type::getType($type),
'default' => 1
);
$this->assertEquals(
' DEFAULT 1',
$this->_platform->getDefaultValueDeclarationSQL($field)
);
}
}
/**
* @group DBAL-45
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment