Commit d639fb86 authored by David Desberg's avatar David Desberg

Applied stof's suggestions

parent 90ff8205
...@@ -898,29 +898,30 @@ class SQLServerPlatform extends AbstractPlatform ...@@ -898,29 +898,30 @@ class SQLServerPlatform extends AbstractPlatform
} }
/** /**
* Obtain DBMS specific SQL code portion needed to set a default value * {@inheritDoc}
* 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) public function getDefaultValueDeclarationSQL($field)
{ {
$default = empty($field['notnull']) ? ' NULL' : ''; if ( ! isset($field['default'])) {
return empty($field['notnull']) ? ' NULL' : '';
}
if (isset($field['default'])) { if ( ! isset($field['type'])) {
$default = " DEFAULT '".$field['default']."'"; return " 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']) . "'";
} }
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;
return " DEFAULT '" . $field['default'] . "'";
} }
} }
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