-
Notifications
You must be signed in to change notification settings - Fork 57
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
BulkMerge failing for tables with decimal columns #294
Comments
Hello @JanSiblik , Are you using MariaDB? If yes, which version? Today we got a very similar issue but with a We will create an issue on their side to know more about it but I believe, we will not have choice and go with your option #2 and use a We will make a decision probably tomorrow to check if we should be pro-active and already do the fix on our side since I'm not sure if their team will try to fix it or not. Please let me know if it's MariaDB, perhaps your is different. |
Hello @JonathanMagnan, Thank you for swift reply. No, we're not using MariaDB, we're on commercial MySQL Enterprise Server, v8.0.17 |
Great, You might be right, I remember vaguely an issue related to v8.x that was not part of the previous version. We will look more deeply at it then start making the fix to cast the column type. |
Hi. Is that solved? If not is there a workaround? I have the same problem with efcore 3 |
Hello @tamys , We will look at it and revisit the history of this JIRA on our side. |
@JonathanMagnan Thank you, The only workaround that worked, and in my case is acceptable but is not a solution, is when the first item of the batch i'm trying to bulkmerge is whole number , i'm adding a penny to force the whole number to become decimal |
Hello @tamys , We indeed probably already been able to reproduce it but it seems my developer currently cannot anymore. He is asking if you could give him what is your sql-mode="STRICT_ALL_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_AUTO_CREATE_USER" Could you also confirm which version of |
Hi @JonathanMagnan |
any update on this? |
Hello @tamys , Sorry for the long waiting, I indeed forget to answer you. We currently have a fix under testing. We don't really like our fix but that's so far the only one we find out. The issue starts with the v8.x when an UPDATE statement uses a derived table. It looks that the decimal doesn't keep correctly his type in this case so the only solution we found is forcing a CAST. A new version with this fix should be released next week. |
Hello @tamys , @JanSiblik The v5.1.4 has been finally released. It should now work with MySQL v8.x If you still have some issues, just let me know which column type is causing it and we will apply the same fix. Best Regards, Jon |
Thanks @JonathanMagnan |
Awesome @tamys ! I'll be looking forward to hearing from you, Jon |
Description
BulkMerge is failing with an exception when trying to update a decimal column that contains mostly (but not exclusively) whole numbers. The error itself is being thrown by MySQL server:
Error Code: 1264. Out of range value for column 'DecimalColumnName' at row 1
But the problem seems to be in the way the update query is actually generated by the BulkMerge extension. Consider having a table SampleValuesTable(
IdColumnName
,IntegerColumnName
,DecimalColumnName
,StringColumnName
) and trying to update it using BulkMerge extension - the resulting query (as seen in the MySQL general_log file) would be as follows:Notice the decimal values of the first two rows are actually whole numbers and are represented without decimal dot. Which is THE issue, really - if the decimal values were all whole numbers or all decimal numbers, the query would execute OK. Even if the first row of the StagingTable would be decimal and all the remaining rows whole numbers, there would be no error. But MySQL cannot (understandably) infer the type of untyped whole number being selected as
DecimalColumnName
and apparently it has trouble re-typing it when performing multiple unions.Proposed solution
Considering the BulkMege extension has the information about the entity being merged, namely it knows the type of 'DecimalColumnName' IS decimal, it could prevent this error easily by generating the decimal values in the resulting query with the decimal dot.
Alternatively it could use CAST() to enforce the data type, which would also work for floating point data types (haven't tried but I suspect it would have the same issue).
It would actually be enough to do this for the first row in the StagingTable, since the type of the further rows in the UNION ALL seems to be inferred from the first one.
Further technical details
The text was updated successfully, but these errors were encountered: