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/sqlite | |
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/sqlite')
-rw-r--r-- | includes/database/sqlite/schema.inc | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/includes/database/sqlite/schema.inc b/includes/database/sqlite/schema.inc index 2d87de657..6830e6b19 100644 --- a/includes/database/sqlite/schema.inc +++ b/includes/database/sqlite/schema.inc @@ -74,7 +74,7 @@ class DatabaseSchema_sqlite extends DatabaseSchema { // Add the SQL statement for each field. foreach ($schema['fields'] as $name => $field) { - if ($field['type'] == 'serial') { + if (isset($field['type']) && $field['type'] == 'serial') { if (isset($schema['primary key']) && ($key = array_search($name, $schema['primary key'])) !== FALSE) { unset($schema['primary key'][$key]); } @@ -116,13 +116,18 @@ class DatabaseSchema_sqlite extends DatabaseSchema { if (!isset($field['size'])) { $field['size'] = 'normal'; } + // Set the correct database-engine specific datatype. - if (!isset($field['sqlite_type'])) { + // In case one is already provided, force it to uppercase. + if (isset($field['sqlite_type'])) { + $field['sqlite_type'] = drupal_strtoupper($field['sqlite_type']); + } + else { $map = $this->getFieldTypeMap(); $field['sqlite_type'] = $map[$field['type'] . ':' . $field['size']]; } - if ($field['type'] == 'serial') { + if (isset($field['type']) && $field['type'] == 'serial') { $field['auto_increment'] = TRUE; } @@ -150,12 +155,17 @@ class DatabaseSchema_sqlite extends DatabaseSchema { else { $sql = $name . ' ' . $spec['sqlite_type']; - if (in_array($spec['type'], array('varchar', 'char', 'text')) && isset($spec['length'])) { + if (in_array($spec['sqlite_type'], array('VARCHAR', 'TEXT')) && isset($spec['length'])) { $sql .= '(' . $spec['length'] . ')'; } - 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['unsigned'])) { |