Bug #44455 insert and update error with entity framework
Submitted: 24 Apr 2009 12:50 Modified: 11 Aug 2009 10:30
Reporter: Gert Brigsted Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:6.0.4 OS:Windows (XP Pro)
Assigned to: Vladislav Vaintroub CPU Architecture:Any
Tags: decimal, entity framework

[24 Apr 2009 12:50] Gert Brigsted
Description:
Same as this one: http://bugs.mysql.com/bug.php?id=43574

Except that I'm from Denmark. The generated sql (grabbed from the query log) looks like this:

		    3 Query	INSERT INTO `product`(
`Name`, 
`Price`) VALUES (
'A new product', 
13,37);

How to repeat:
DROP TABLE IF EXISTS `blah`.`product`;
CREATE TABLE  `blah`.`product` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Name` varchar(45) NOT NULL,
  `Price` double NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

Suggested fix:
Make decimal values always use dot instead of comma, as the comma is always used to separate multiple values.
[24 Apr 2009 15:24] Tonci Grgin
Hi Gert and thanks for your report. I was about to test it but I hit Bug#44460... Will see how to test this next week.
[7 May 2009 11:07] Tonci Grgin
Hi Gert. I would like you to attach small but complete test case demonstrating this behavior. In the meantime, I'll look for localized version of Windows with comma as decimal separator.
[29 May 2009 17:19] Gert Brigsted
Hi again. I was just wondering if you can see the example project I submitted? I set it to only be visible to developers, although I can't remember why... :)
[20 Jun 2009 9:56] Tonci Grgin
Yes Gert, I see it :-). So far I simply had no time to check on your report. Will do after vacation.
[23 Jul 2009 7:51] Tonci Grgin
True, verified as described using test case attached.

I changed my locale to use decimal comma, modified AssemblyInfo.cs, [assembly: AssemblyCulture("")] to "sl" and "de" (both using decimal comma) and added MySQL assemblies to Web.config:
	<add assembly="MySql.Data.Entity, Version=6.0.4.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/> (instead of System.Data.EntityClient)
	<add assembly="MySql.Data, Version=6.0.4.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
but to no avail...

Server Error in '/' Application.
Column count doesn't match value count at row 1
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: MySql.Data.MySqlClient.MySqlException: Column count doesn't match value count at row 1

Source Error:

Line 20: 			{
Line 21: 				Product product = Product.CreateProduct(0, "False teeth", 13.37);
Line 22: 				database.AddToProducts(product);
Line 23: 				database.SaveChanges(); // This line fails.
Line 24: 			}

Source File: F:\PublicShare\temp\Bug44455\MysqlBug\MysqlBug.Test\Default.aspx.cs    Line: 22

Stack Trace:

[MySqlException (0x80004005): Column count doesn't match value count at row 1]
   MySql.Data.MySqlClient.MySqlStream.ReadPacket() +216
   MySql.Data.MySqlClient.NativeDriver.ReadResult(UInt64& affectedRows, Int64& lastInsertId) +60
   MySql.Data.MySqlClient.MySqlDataReader.GetResultSet() +49
   MySql.Data.MySqlClient.MySqlDataReader.NextResult() +722
   MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) +936
   MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +4
   System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) +10
   System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary`2 identifierValues, List`1 generatedValues) +209
   System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter) +281

This differs from Bug#43574 in that DOUBLE and not decimal is used. As I can not access the patch right now I guess only decimal was handled in it.
[10 Aug 2009 17:38] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/80462

744 Reggie Burnett	2009-08-10
      - fixed formatting of single, double, and decimal values when used with entity framework
        in cultures that use the comma as a decimal separator (bug #44455)
[10 Aug 2009 17:39] Reggie Burnett
fixed in 6.0.5 and 6.1.1
[11 Aug 2009 10:30] Tony Bedford
An entry was added to the 6.0.5 and 6.1.1 changelog:

Errors occurred when using the Entity Framework with cultures that used a comma as the decimal separator. This was because the formatting for SINGLE, DOUBLE and DECIMAL values was not handled correctly.