Currency type is incorrectly converted for HSQLDB

Description

For HsqlDatabase, CurrencyType#toDatabaseDataType converts currency columns to a simple DECIMAL type without specifying a precision or scale. This is specified by the method's default return:

Under normal operation, HSQLDB does not apply a default scale to DECIMAL typed columns. This is a problem because HSQLDB treats DECIMAL columns without a scale as integral types. So when I insert data into the currency typed columns Liquibase creates in my HSQLDB integration databases, the values are rounded up to the nearest whole number and are indeed stored as integral values.

I believe CurrencyType#toDatabaseDataType should be modified to return a DECIMAL datatype with an explicit precision and scale for HsqlDatabase instances, similar to the types returned for DB2 and Firebird. Although, I'm not sure what precision and scale are most appropriate since there's no obvious consistency with regard to those used for other database vendors in that same method.

For now, I'm working around the issue by creating a custom data type that extends CurrencyType:

HSQLDB Reference

http://hsqldb.org/doc/2.0/guide/sqlgeneral-chapt.html#sgc_numeric_types

The decimal precision and scale of NUMERIC and DECIMAL types can be optionally defined. For example, DECIMAL(10,2) means maximum total number of digits is 10 and there are always 2 digits after the decimal point, while DECIMAL(10) means 10 digits without a decimal point.
...
Note: If a database has been set to ignore type precision limits with the SET DATABASE SQL SIZE FALSE command, then a type definition of DECIMAL with no precision and scale is treated as DECIMAL(100,10). In normal operation, it is treated as DECIMAL(100).

Environment

macOS Sierra (10.12.6), HSQLDB 2.3.4

Activity

Show:

Details

Reporter

Components

Affects versions

Priority

Created March 14, 2018 at 7:24 PM
Updated March 14, 2018 at 7:24 PM