| Bug #88058 | DECIMAL with NumericScale of 0 has wrong NumericPrecision in GetSchemaTable | ||
|---|---|---|---|
| Submitted: | 11 Oct 2017 12:50 | Modified: | 8 Jan 2018 21:47 |
| Reporter: | Bradley Grainger (OCA) | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector / NET | Severity: | S3 (Non-critical) |
| Version: | 6.9.9 | OS: | Windows (10.0.15063 x64) |
| Assigned to: | CPU Architecture: | Any | |
[11 Oct 2017 13:34]
Chiranjeevi Battula
Hello Bradley Grainger, Thank you for the bug report and test case. Verified this behavior on Visual Studio 2013 (C#.Net) and Connector/NET 6.9.9 version. Thanks, Chiranjeevi.
[11 Oct 2017 13:34]
Chiranjeevi Battula
Screenshot
Attachment: 88058.JPG (image/jpeg, text), 151.49 KiB.
[8 Jan 2018 21:47]
Christine Cole
Posted by developer: Fixed as of the upcoming MySQL Connector/NET 6.9.11 release, and here's the changelog entry: When a decimal column was defined with a scale of zero, such as DECIMAL(8, 0), the value of the NumericPrecision field returned by the MySqlDataReader.GetSchemaTable method was lower by one. For example, it returned 7 instead of 8 as expected. Thank you for the bug report.

Description: When a decimal column is defined with a scale of 0 (e.g., DECIMAL(8, 0)), the "NumericPrecision" value returned by GetSchemaTable is off by one. How to repeat: Execute the following SQL: create schema schema_table collate utf8_bin; create table schema_table.datatypes( decimal0 decimal(8, 0) ); Then run this C# code: using (var connection = new MySqlConnection("...")) { connection.Open(); using (var cmd = connection.CreateCommand()) { cmd.CommandText = "SELECT * FROM schema_table.datatypes;"; using (var reader = cmd.ExecuteReader()) { var schemaTable = reader.GetSchemaTable(); Console.WriteLine(schemaTable.Rows[0]["NumericPrecision"]); // prints 7, expected 8 } } } Suggested fix: At https://github.com/mysql/mysql-connector-net/blob/5864e6b21a8b32f5154b53d1610278abb3cb1cee..., if field.Scale==0, add one to field.Precision for the omitted decimal point.