Commit d8709c5c authored by Shane Archer's avatar Shane Archer Committed by Marco Pivetta

Added unit test for DateTime/DateTimeTz default timestamps; made same change for SQL server.

parent 1d92a8ee
......@@ -1458,7 +1458,7 @@ class SQLServerPlatform extends AbstractPlatform
return " DEFAULT " . $field['default'];
}
if ((string) $field['type'] == 'DateTime' && $field['default'] == $this->getCurrentTimestampSQL()) {
if (in_array((string) $field['type'], array('DateTime', 'DateTimeTz')) && $field['default'] == $this->getCurrentTimestampSQL()) {
return " DEFAULT " . $this->getCurrentTimestampSQL();
}
......
......@@ -440,6 +440,29 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this->markTestSkipped('Platform does not support Column comments.');
}
public function testGetDefaultValueDeclarationSQL()
{
// timestamps on datetime types should not be quoted
foreach (array('datetime', 'datetimetz') as $type) {
$field = array(
'type' => Type::getType($type),
'default' => $this->_platform->getCurrentTimestampSQL()
);
$this->assertEquals(' DEFAULT ' . $this->_platform->getCurrentTimestampSQL(), $this->_platform->getDefaultValueDeclarationSQL($field));
}
// non-timestamp value will get single quotes
$field = array(
'type' => 'string',
'default' => 'non_timestamp'
);
$this->assertEquals(" DEFAULT 'non_timestamp'", $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