diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-10-22 15:18:56 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-10-22 15:18:56 +0000 |
commit | 748d7ea037ca1857977c825cbee25b61ff0c5ea7 (patch) | |
tree | fc653a9f8aef695345e870b463f3c07036b95ac8 /includes/database/mysql | |
parent | 4acbcf6d8fc2b24e2c31a573913aa69283efb6bd (diff) | |
download | brdo-748d7ea037ca1857977c825cbee25b61ff0c5ea7.tar.gz brdo-748d7ea037ca1857977c825cbee25b61ff0c5ea7.tar.bz2 |
#927828 by Damien Tournoud, LaurentAjdnik, boombatower: Fixed contrib can't specify custom schema types. Should fix Date module. Yay.
Diffstat (limited to 'includes/database/mysql')
-rw-r--r-- | includes/database/mysql/schema.inc | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/includes/database/mysql/schema.inc b/includes/database/mysql/schema.inc index cba41eb5f..ff1d99ba8 100644 --- a/includes/database/mysql/schema.inc +++ b/includes/database/mysql/schema.inc @@ -132,7 +132,7 @@ class DatabaseSchema_mysql extends DatabaseSchema { protected function createFieldSql($name, $spec) { $sql = "`" . $name . "` " . $spec['mysql_type']; - if (in_array($spec['type'], array('varchar', 'char', 'text')) && isset($spec['length'])) { + if (in_array($spec['mysql_type'], array('VARCHAR', 'CHAR', 'TINYTEXT', 'MEDIUMTEXT', 'LONGTEXT', 'TEXT')) && isset($spec['length'])) { $sql .= '(' . $spec['length'] . ')'; } elseif (isset($spec['precision']) && isset($spec['scale'])) { @@ -143,8 +143,13 @@ class DatabaseSchema_mysql extends DatabaseSchema { $sql .= ' unsigned'; } - if (!empty($spec['not null'])) { - $sql .= ' NOT NULL'; + if (isset($spec['not null'])) { + if ($spec['not null']) { + $sql .= ' NOT NULL'; + } + else { + $sql .= ' NULL'; + } } if (!empty($spec['auto_increment'])) { @@ -187,12 +192,16 @@ class DatabaseSchema_mysql extends DatabaseSchema { } // Set the correct database-engine specific datatype. - if (!isset($field['mysql_type'])) { + // In case one is already provided, force it to uppercase. + if (isset($field['mysql_type'])) { + $field['mysql_type'] = drupal_strtoupper($field['mysql_type']); + } + else { $map = $this->getFieldTypeMap(); $field['mysql_type'] = $map[$field['type'] . ':' . $field['size']]; } - if ($field['type'] == 'serial') { + if (isset($field['type']) && $field['type'] == 'serial') { $field['auto_increment'] = TRUE; } |