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

Use ToString when value returned from GetValue is not a string type. #407

Conversation

robertbeuligmann
Copy link

#406 Changes Row.GetString to mimic the MySql.Data GetString by using ToString() for non-string type column.

@bgrainger
Copy link
Member

The current (strict) behaviour is by design; I plan to add more GetValue/GetX tests to https://github.com/mysql-net/AdoNetApiTest to check the common approach to this across other connectors, and will wait on making any decision on this until then.

public string GetString(int ordinal)
{
var value = GetValue(ordinal);
return value is string stringValue ? stringValue : value.ToString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a culture-sensitive conversion the right thing to do here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robertbeuligmann
Copy link
Author

robertbeuligmann commented Nov 29, 2017

Having GetString not automatically convert columns to string is a major blocking change from the default MySql.Data implementation for the project I would like to convert to MySqlConnector.

@bgrainger
Copy link
Member

Opened mysql-net/AdoNetApiTest#4 for the data type conversion investigation.

@bgrainger
Copy link
Member

Closing this since a culture-sensitive conversion of a retrieved value to a string is likely to be buggy, and since GetValue(x).ToString() is a possible workaround.

@bgrainger bgrainger closed this Jul 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants