public function testGetDefaultValueDeclarationSQLForIntegerTypes()
 {
     foreach (array('bigint', 'integer', 'smallint') as $type) {
         $field = array('type' => Type::getType($type), 'default' => 1);
         $this->assertEquals(' DEFAULT 1', $this->_platform->getDefaultValueDeclarationSQL($field));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getDefaultValueDeclarationSQL($field)
 {
     // Unset the default value if the given field definition does not allow default values.
     if ($field['type'] instanceof TextType || $field['type'] instanceof BlobType) {
         $field['default'] = null;
     }
     return parent::getDefaultValueDeclarationSQL($field);
 }
Beispiel #3
0
 /**
  * {@inheritDoc}
  */
 public function getDefaultValueDeclarationSQL($field)
 {
     if (!empty($field['autoincrement'])) {
         return '';
     }
     if (isset($field['version']) && $field['version']) {
         if ((string) $field['type'] != "DateTime") {
             $field['default'] = "1";
         }
     }
     return parent::getDefaultValueDeclarationSQL($field);
 }
Beispiel #4
0
 public function getDefaultValueDeclarationSQL($field)
 {
     if (isset($field['notnull']) && $field['notnull'] && !isset($field['default'])) {
         if (in_array((string) $field['type'], array("Integer", "BigInteger", "SmallInteger"))) {
             $field['default'] = 0;
         } else {
             if ((string) $field['type'] == "DateTime") {
                 $field['default'] = "00-00-00 00:00:00";
             } else {
                 if ((string) $field['type'] == "Date") {
                     $field['default'] = "00-00-00";
                 } else {
                     if ((string) $field['type'] == "Time") {
                         $field['default'] = "00:00:00";
                     } else {
                         $field['default'] = '';
                     }
                 }
             }
         }
     }
     unset($field['default']);
     // @todo this needs fixing
     if (isset($field['version']) && $field['version']) {
         if ((string) $field['type'] != "DateTime") {
             $field['default'] = "1";
         }
     }
     return parent::getDefaultValueDeclarationSQL($field);
 }