Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetDouble and GetFloat less type auto conversion #664

Closed
dczuo opened this issue Jun 28, 2019 · 4 comments
Closed

GetDouble and GetFloat less type auto conversion #664

dczuo opened this issue Jun 28, 2019 · 4 comments

Comments

@dczuo
Copy link

dczuo commented Jun 28, 2019

simple example:
using (var reader = new MySqlCommand("select 1 / 3 from tablename", conn).ExecuteReader())
{
reader.Read();
reader.GetDouble(0); // InvalidCastException
reader.GetFloat(0); // InvalidCastException
}

@bgrainger
Copy link
Member

MySqlConnector currently only performs a small number of known "safe" conversions; see #481 and #406.

Note that a decimal column can be retrieved as an int (#54) so it may make sense to allow implicit conversion to float/double (which would be less lossy).

Like similar issues, this needs testing in AdoNetApiTest first.

@bgrainger
Copy link
Member

Added to AdoNetApiTest: mysql-net/AdoNetApiTest@2a48acc

Conversions from a decimal column (or implicit decimal result) will be handled automatically by GetDouble and GetFloat.

@bgrainger
Copy link
Member

Fix shipped in 0.57.0-rc1.

@dczuo
Copy link
Author

dczuo commented Sep 7, 2019

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants