vapor / mysql-nio

🐬 Non-blocking, event-driven Swift client for MySQL.
MIT License
87 stars 28 forks source link

Fix decimal handling for MySQLData #35

Closed nostradani closed 3 years ago

nostradani commented 4 years ago

Improves Foundation.Decimal support on MySQLData (#35).

tanner0101 commented 3 years ago

Original comment:


We noticed that our test application would run into an issue when using decimal numbers. We are using MySQL 5.7.29:

In our case we have a table with one row of type DECIMAL(19,4). When querying the database for that field using a model with a property of type Decimal, the conversion would fail.

The query wouldn't return the decimal value as string, but instead use type MYSQL_TYPE_NEWDECIMAL (which makes sense).

Also the unit test for decimal values seems to be broken since it doesn't not query for a decimal value.

The patch should introduce a correct behaviour while also allowing other types to be converted to a decimal value.

tanner0101 commented 3 years ago

These changes are now available in 1.0.0-rc.2.5