Bug #115168 | MySqlDataReader.Get<Type> may not return the correct value. | ||
---|---|---|---|
Submitted: | 29 May 2024 20:17 | Modified: | 13 Dec 2024 23:31 |
Reporter: | David Ellingsworth | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | Connector / NET | Severity: | S2 (Serious) |
Version: | OS: | Any | |
Assigned to: | CPU Architecture: | Any |
[29 May 2024 20:17]
David Ellingsworth
[30 May 2024 13:02]
MySQL Verification Team
Hello David, Thank you for the report. Could you please provide a test case(snippet of C/NET code) to reproduce this issue at our end? Regards, Ashwini Patil
[30 May 2024 18:29]
David Ellingsworth
Assuming a connection and table have already been created, a simple test would be as follows. Note: None of this has been syntax or compile checked. decimal expectedValue = 12.3m; // Set the current locale to the invariant culture. CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; // Insert the decimal value into the database. using (var cmd = connection.CreateCommand()) { cmd.CommandText = "Insert Into TestTable(TextColumn) Values (@pDateTime)"; var pDateTime = cmd.CreateDbParameter(); pDateTime.ParameterName = "@pDateTime"; pDateTime.DbType = DbType.Decimal; pDateTime.Value = expectedValue; cmd.Parameters.Add(pDateTime); cmd.ExecuteNonQuery(); } // Set the current locale to de-DE before retrieving the value to simulate performing // the query on a computer in another region. CultureInfo.CurrentCulture = CultureInfo.GetCulture("de-DE"); using (var cmd = connection.CreateCommand()) { cmd.CommandText = "Select TextColumn from TestTable"; using (var reader = cmd.ExecuteReader()) { while(reader.Read()) { decimal dbValue = reader.GetDecimal("TextColumn"); Assert.AreEqual(expectedValue, dbValue); } } }
[10 Jun 2024 12:44]
MySQL Verification Team
Hello David, Thank you for the details. Verified as described. Regards, Ashwini Patil
[13 Dec 2024 23:31]
Omar Chavez
Posted by developer: This is not a bug, the driver converts the string value from the column using the current Culture of the system, the driver is not in charge of determining the Culture or the decimal separator to be used.