Skip to content

Commit

Permalink
Fixed SQL Server Platform NULL declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
David Desberg authored and beberlei committed Nov 25, 2012
1 parent b961a3f commit 1636611
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
Expand Up @@ -862,4 +862,31 @@ public function getBlobTypeDeclarationSQL(array $field)
{
return 'VARBINARY(MAX)';
}

/**
* Obtain DBMS specific SQL code portion needed to set a default value
* declaration to be used in statements like CREATE TABLE.
*
* @param array $field field definition array
*
* @return string DBMS specific SQL code portion needed to set a default value
*/
public function getDefaultValueDeclarationSQL($field)
{
$default = empty($field['notnull']) ? ' NULL' : '';

if (isset($field['default'])) {
$default = " DEFAULT '".$field['default']."'";
if (isset($field['type'])) {
if (in_array((string)$field['type'], array("Integer", "BigInteger", "SmallInteger"))) {
$default = " DEFAULT ".$field['default'];
} else if ((string)$field['type'] == 'DateTime' && $field['default'] == $this->getCurrentTimestampSQL()) {
$default = " DEFAULT ".$this->getCurrentTimestampSQL();
} else if ((string) $field['type'] == 'Boolean') {
$default = " DEFAULT '" . $this->convertBooleans($field['default']) . "'";
}
}
}
return $default;
}
}

0 comments on commit 1636611

Please sign in to comment.