Commit 60a19586 authored by Steve Müller's avatar Steve Müller

Merge pull request #671 from josemalonsom/fix-quoted-integers-as-default-value

Fix quoted integers as default value.
parents 1c9c24a7 df299d79
...@@ -2241,7 +2241,7 @@ abstract class AbstractPlatform ...@@ -2241,7 +2241,7 @@ abstract class AbstractPlatform
if (isset($field['default'])) { if (isset($field['default'])) {
$default = " DEFAULT '".$field['default']."'"; $default = " DEFAULT '".$field['default']."'";
if (isset($field['type'])) { 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']; $default = " DEFAULT ".$field['default'];
} elseif (in_array((string) $field['type'], array('DateTime', 'DateTimeTz')) && $field['default'] == $this->getCurrentTimestampSQL()) { } elseif (in_array((string) $field['type'], array('DateTime', 'DateTimeTz')) && $field['default'] == $this->getCurrentTimestampSQL()) {
$default = " DEFAULT ".$this->getCurrentTimestampSQL(); $default = " DEFAULT ".$this->getCurrentTimestampSQL();
......
...@@ -1454,7 +1454,7 @@ class SQLServerPlatform extends AbstractPlatform ...@@ -1454,7 +1454,7 @@ class SQLServerPlatform extends AbstractPlatform
return " DEFAULT '" . $field['default'] . "'"; 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']; return " DEFAULT " . $field['default'];
} }
......
...@@ -466,6 +466,21 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase ...@@ -466,6 +466,21 @@ 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 * @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