Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed SQL Server Platform NULL declaration

  • Loading branch information...
commit 336441a358826714dc98f1689791d83413988e4f 1 parent 6876437
David Desberg authored
Showing with 27 additions and 0 deletions.
  1. +27 −0 lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
View
27 lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
@@ -896,4 +896,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;
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.