Bug #5900 serializing of floating point parameters (double, numeric, single, decimal)
Submitted: 5 Oct 2004 14:54 Modified: 13 Oct 2004 17:24
Reporter: Roman Kunert Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:1.0.0 OS:Windows (Windows 2000)
Assigned to: Reggie Burnett CPU Architecture:Any

[5 Oct 2004 14:54] Roman Kunert
Description:
Method SerializeToText() from class MySqlParameter does not care about national type conversion differences for floating point types:

all numeric variables get serialized with the call:

valStr = paramValue.ToString();

in many local environments this call will for example convert the double 6.7d into "6,7", as a comma is used for the delimeter instead of the dot

this results in a complaint about a difference between the number of parameters and the number of variables (because variables are comma seperated and "6,7" now represent two values)

How to repeat:
see description

Suggested fix:
to fix this quickly I changed the method SerializeToText as follows (it works for me now, but a more elegant solution should be found):

internal void SerializeToText(...) 
{

...

if (paramValue is MySqlDateTime) 
{
  valStr = (paramValue as MySqlDateTime).ToMySqlString(conn.InternalConnection.Driver.Version.isAtLeast(4,1,0));
}	

// we have to take care of national differences regarding the decimal delimiters 
else if(paramValue is MySqlNumber || paramValue is MySqlSingle || paramValue is MySqlDouble || paramValue is MySqlDecimal) 
{
  valStr = paramValue.ToString().Replace(",",".");
} 
else 
{
  valStr = paramValue.ToString();
}
...
}
[13 Oct 2004 17:24] Reggie Burnett
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html