Commit 22a30c9c authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge branch 'DBAL-387' into 2.3

parents ef930a7f ef02cc72
......@@ -896,4 +896,32 @@ class SQLServerPlatform extends AbstractPlatform
{
return 'VARBINARY(MAX)';
}
/**
* {@inheritDoc}
*/
public function getDefaultValueDeclarationSQL($field)
{
if ( ! isset($field['default'])) {
return empty($field['notnull']) ? ' NULL' : '';
}
if ( ! isset($field['type'])) {
return " DEFAULT '" . $field['default'] . "'";
}
if (in_array((string) $field['type'], array('Integer', 'BigInteger', 'SmallInteger'))) {
return " DEFAULT " . $field['default'];
}
if ((string) $field['type'] == 'DateTime' && $field['default'] == $this->getCurrentTimestampSQL()) {
return " DEFAULT " . $this->getCurrentTimestampSQL();
}
if ((string) $field['type'] == 'Boolean') {
return " DEFAULT '" . $this->convertBooleans($field['default']) . "'";
}
return " DEFAULT '" . $field['default'] . "'";
}
}
......@@ -14,13 +14,13 @@ class SQLServerPlatformTest extends AbstractPlatformTestCase
public function getGenerateTableSql()
{
return 'CREATE TABLE test (id INT IDENTITY NOT NULL, test NVARCHAR(255) DEFAULT NULL, PRIMARY KEY (id))';
return 'CREATE TABLE test (id INT IDENTITY NOT NULL, test NVARCHAR(255) NULL, PRIMARY KEY (id))';
}
public function getGenerateTableWithMultiColumnUniqueIndexSql()
{
return array(
'CREATE TABLE test (foo NVARCHAR(255) DEFAULT NULL, bar NVARCHAR(255) DEFAULT NULL)',
'CREATE TABLE test (foo NVARCHAR(255) NULL, bar NVARCHAR(255) NULL)',
'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar) WHERE foo IS NOT NULL AND bar IS NOT NULL'
);
}
......@@ -28,7 +28,7 @@ class SQLServerPlatformTest extends AbstractPlatformTestCase
public function getGenerateAlterTableSql()
{
return array(
'ALTER TABLE mytable ADD quota INT DEFAULT NULL',
'ALTER TABLE mytable ADD quota INT NULL',
'ALTER TABLE mytable DROP COLUMN foo',
'ALTER TABLE mytable ALTER COLUMN baz NVARCHAR(255) DEFAULT \'def\' NOT NULL',
'ALTER TABLE mytable ALTER COLUMN bloo BIT DEFAULT \'0\' NOT NULL',
......
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