Closed
Description
Software versions
MySqlConnector version: 2.2.7
Server type (MySQL, MariaDB, Aurora, etc.) and version: MySQL 8.0
.NET version: 7.0
Describe the bug
MySqlDataReader.GetMySqlDecimal
can't read a value from a column with the ZEROFILL
attribute.
Exception
FormatException: Could not parse the value as a MySqlDecimal: 0000000000.0000000000
at MySqlConnector.MySqlDecimal..ctor(String value) in C:\Code\MySql\MySqlConnector\src\MySqlConnector\MySqlDecimal.cs:line 46
at MySqlConnector.Core.Row.GetMySqlDecimal(Int32 ordinal) in C:\Code\MySql\MySqlConnector\src\MySqlConnector\Core\Row.cs:line 415
at MySqlConnector.MySqlDataReader.GetMySqlDecimal(Int32 ordinal) in C:\Code\MySql\MySqlConnector\src\MySqlConnector\MySqlDataReader.cs:line 276
at UserQuery.Main(), line 33
Code sample
drop table if exists dectest;
create table dectest(value decimal(20,10) zerofill);
insert into dectest(value) values(0),(1),(0.1);
using var cmd = new MySqlCommand("select value from dectest", connection);
using var reader = cmd.ExecuteReader();
while (reader.Read())
reader.GetMySqlDecimal(0).Dump();
Expected behavior
Reads the column value as a MySqlDecimal
.
Additional context
Reported here: #1075 (comment)