The db_type_map() function for mysql declares that the Schema API type 'numeric' maps to the mysql type 'numeric'. This works fine, but mysql treats 'numeric' as an alias for its native type 'decimal'. Thus, if you create a column with a Schema API type of 'numeric', when schema.module inspects the database, mysql says the column is of type 'decimal', and schema.module reports an error where none exists.

I can work around this in schema.module but the right solution is to use the correct native type name in core. Trivial patch attached.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bjaspan’s picture

I left out a step in my explanation.

When schema.module inspects the database and learns that table foo column bar is of type 'decimal', it looks through the results of db_type_map() for which Schema API data type maps to the mysql type 'decimal'. It doesn't find one (because currently the type map lists 'numeric'), and reports an error.

hass’s picture

subscribe :-)

bjaspan’s picture

Title: mysql type for 'numeric' is called DECIMAL » db_type_map() should use base type names, not aliases
FileSize
1.27 KB

Exactly the same problem exists with pgsql's Schema type char:normal. It maps to 'char' but should map to 'character'. Again, worked around in schema.module but should be fixed in core.

New patch attached.

hass’s picture

@bjaspan: isn't this not critical for the final release?

chx’s picture

Status: Needs review » Reviewed & tested by the community

Trivial indeed.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.