-
Notifications
You must be signed in to change notification settings - Fork 386
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
NO_BACKSLASH_ESCAPES support in 3.0 and MySqlConnect #827
Comments
Yes, it sounds like MySqlConnector needs support for this SQL mode. (Interestingly, there have been no requests for this until now; I assume it's not very common?) |
This seems to be even weirder than I thought. I have created a couple of tests to run against MySqlConnector and the original Connector/ODBC 8.0. As it turns out, Connector/ODBC 8.0 handles NO_BACKSLASH_ESCAPES even worse. It doesn't mean, that it should not be implemented, but MySqlConnector would need to detect, if the NO_BACKSLASH_ESCAPES mode has been set or not. |
It is an even less common case for EF Core, because it is mostly irrelevant as long as the user is not executing raw SQL queries over the same connection. It has been reference with #670 and #667 in this repo. There is a StackOverflow post regarding the general issue, but it is not entirely correct in what it states. @bgrainger The big question is, if you would be okay with either tracking/detecting Implementation:To track the mode, the incomming queries would need to be parsed to some extend. Probably looking for To detect the mode, it would have to be queries before every query execution. So two round trips instead of one for every query. For the opt-in setting, there just needs to be added a property of some sort. |
Doesn't it affect any parameterised query? By default, MySqlConnector will escape
Although detecting the SQL mode automatically would be the most convenient for users, I'd prefer an opt-in setting (in the connection string). To detect the SQL mode at runtime, we'd have to issue a query to the database server every time a connection is opened. That would be a performance penalty for all users (for what appears to be a very infrequently used SQL mode). Is having a connection string setting (that Pomelo EFCore can set if |
A connection string setting works for us.
Yes, I meant that the whole mode should not really be needed, if there is no raw sql being executed by the Pomelo.MySql user. Without With The thing is that, as long as the user is not executing sql statements on his own, he doesn't need to care how they are being translated, as long as they are being saved and retrieved correctly. So as far as I can see, Anyway, I think |
…derived classes and MySqlParameter. Single Quotes are now always escaped with two single quotes instead of a leading backspace. This addresses everything except triggering/detecting the NO_BACKSLASH_ESCAPES from mysql-net#701 and PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#827
…derived classes and MySqlParameter. Single quotes are now always escaped with an additional single quote instead of a leading backspace. This addresses everything except triggering/detecting the NO_BACKSLASH_ESCAPES from mysql-net#701 and PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#827
…derived classes and MySqlParameter. Single quotes are now always escaped with an additional single quote instead of a leading backspace. This addresses everything except triggering/detecting the NO_BACKSLASH_ESCAPES from mysql-net#701 and PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#827
…derived classes and MySqlParameter. Single quotes are now always escaped with an additional single quote instead of a leading backspace. This addresses everything except triggering/detecting the NO_BACKSLASH_ESCAPES from mysql-net#701 and PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#827 Signed-off-by: Laurents Meyer <[email protected]>
…derived classes and MySqlParameter. Single quotes are now always escaped with an additional single quote instead of a leading backspace. This addresses everything except triggering/detecting the NO_BACKSLASH_ESCAPES from #701 and PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#827 Signed-off-by: Laurents Meyer <[email protected]>
…derived classes and MySqlParameter. Single quotes are now always escaped with an additional single quote instead of a leading backspace. This addresses everything except triggering/detecting the NO_BACKSLASH_ESCAPES from #701 and PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#827 Signed-off-by: Laurents Meyer <[email protected]>
…derived classes and MySqlParameter. Single quotes are now always escaped with an additional single quote instead of a leading backspace. This addresses everything except triggering/detecting the NO_BACKSLASH_ESCAPES from #701 and PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#827 Signed-off-by: Laurents Meyer <[email protected]>
This feature is now fully supported by MySqlConnector. @bgrainger I will also do a quick test today, if the improved datatype handling (casting to similar types before returning to the caller) is sufficient now, so we can drop This would conclude all the currently needed changes for the 3.0.0 release from MySqlConnector. |
MySqlConnector 0.58.0 is now available on NuGet. |
I updated all dependencies to .NET Core 3.0 and MySqlConnector to 0.58.0. There are 10 more failing tests with |
The only missing conversion is hit, when the query is returning a This can happen, because of the workaround that is used for The workaround is able to convert a value to a double, but not to a float. Pomelo.EntityFrameworkCore.MySql/src/EFCore.MySql/Query/Internal/MySqlQuerySqlGenerator.cs Lines 214 to 247 in ed38395
So |
https://www.nuget.org/packages/MySqlConnector/0.59.0 is available to fix this conversion. |
* Remove bug comment. This is still a bug, but as it turns out, exists for all join conditions, not just those in derived tables when using LATERAL. * Current state of NO_BACKSLASH_ESCAPES implementation. Still needs work. * Implement proper test cases for MySqlConnector's new NO_BACKSLASH_ESCAPES support. See #827 * Fully implement NO_BACKSLASH_ESCAPES support, based on implemented support of MySqlConnector. * Give "Escapes" fixtures their own StoreName, to separate them from the regular Northwind fixtures, because of the additional Customer, so they don't get accidentally shared. * Add missing UpdateSqlModeOnOpen to constructor. * Correct and expand code docs. Simplify SetSqlModeOnOpen usage. * Fix local debugging support (Resharper source files etc.), that broke with new CI/Arcade setup.
We used to work around errors in the
NO_BACKSLASH_ESCAPES
handling of MySqlConnector (and the original Net/Connector btw) for parameters with strings containing single quotes, by inlining all parameters into literals/constants, before executing theMySqlCommand
.I did reimplement this behavior for 3.0 and extended it to support
UPDATE
andINSERT
statements as well (not pushed yet).But since this is actually working around issues in MySqlConnector itself, we should fix those errors there (resp. add propper support for
NO_BACKSLASH_ESCAPES
there), so there is no need for specific workarounds anymore.I will open an issue for that in the MySqlConnect repo, provide some test code and probably even a PR to fix the
SqlParser
state machine for properNO_BACKSLASH_ESCAPES
handling./cc @bgrainger
The text was updated successfully, but these errors were encountered: