diff --git a/engines/mysql.inc b/engines/mysql.inc index f86aaa3..69bca67 100644 --- a/engines/mysql.inc +++ b/engines/mysql.inc @@ -20,10 +20,28 @@ class SchemaDatabaseSchema_mysql extends DatabaseSchema_mysql { return parent::createTableSql($name, $table); } + /** + * Fetch the type map from the core and extend it to cover non Drupal types + */ + public function schema_field_type_map() { + static $map; + if (!isset($map)) { + // Get the core map. + $map = $this->getFieldTypeMap(); + + // Add our extensions. + $map += array( + 'datetime:normal' => 'DATETIME', + ); + } + return $map; + } + + public function schema_type_map() { static $map; if (!isset($map)) { - $map = array_flip(array_map('strtolower', $this->getFieldTypeMap())); + $map = array_flip(array_map('strtolower', $this->schema_field_type_map())); } return $map; } diff --git a/engines/pgsql.inc b/engines/pgsql.inc index 6accfa0..bfc1678 100644 --- a/engines/pgsql.inc +++ b/engines/pgsql.inc @@ -20,10 +20,24 @@ class SchemaDatabaseSchema_pgsql extends DatabaseSchema_pgsql { return parent::createTableSql($name, $table); } + /** + * Fetch the type map from the core and extend it to cover non Drupal types + */ + public function schema_field_type_map() { + static $map; + if (!isset($map)) { + // Get the core map. + $map = $this->getFieldTypeMap(); + + // Add our extensions. + } + return $map; + } + public function schema_type_map() { static $map; if (!isset($map)) { - $map = array_flip(array_map('strtolower', $this->getFieldTypeMap())); + $map = array_flip(array_map('strtolower', $this->schema_field_type_map())); $map['character varying'] = 'varchar:normal'; $map['integer'] = 'int:normal'; } diff --git a/schema.module b/schema.module index d1bf7ce..e4f0723 100755 --- a/schema.module +++ b/schema.module @@ -186,7 +186,7 @@ function schema_dbobject() { * Converts a column's Schema type into an engine-specific data type. */ function schema_engine_type($col, $table, $field, $engine = NULL) { - $map = schema_dbobject()->getFieldTypeMap(); + $map = schema_dbobject()->schema_field_type_map(); $size = (isset($col['size']) ? $col['size'] : 'normal'); $type = $col['type'] . ':' . $size; if (isset($map[$type])) {