-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Case-sensitive parameter names #18861
Comments
@zabolotnev Thanks for filing this issue. We will discuss in our next triage meeting. /cc @bricelam |
Parameters are case-sensitive in SQLite: command.CommandText = "SELECT $A, $a, @A, @a, :A, :a";
command.Parameters.AddWithValue("$A", 1L);
command.Parameters.AddWithValue("$a", 2L);
command.Parameters.AddWithValue("@A", 3L);
command.Parameters.AddWithValue("@a", 4L);
command.Parameters.AddWithValue(":A", 5L);
command.Parameters.AddWithValue(":a", 6L); It would be a nice enhancement, however, to be case-forgiving when the name is not ambiguous. |
Hi, I want to contribute to an open source project for the first time, and since this issue has a "good first issue" tag I would like to try this one. I already downloaded the project and saw where I could do the change. I can already start? |
@thiagokoster Feel free to submit a PR. We can work through any implementation details there that come up. |
Hi @bricelam, is this still up for grabs? @thiagokoster, do you still want to take this one? |
Yep, go for it |
Sorry for not commenting earlier on this issue, but I think we shouldn't do this change for performance reasons. In a nutshell, it originally seemed reasonable perf-wise to only attempt insensitive matching if sensitive matching fails - this way perf isn't affected for the case-sensitive scenario. However, it turns out the it's common for code to first check if a parameter name is already present in the collection, and only then add it; Dapper notably does this. This means two dictionary lookups just for that check, and things get worse as lots of parameters are added. FYI in Npgsql we've done case-insensitive parameter name matching up to now (because SqlClient does them), but are changing that behavior by default for 6.0 (with an AppContext switch for the legacy case-insensitive behavior). See the full details (and Dapper info) in npgsql/npgsql#4027 (plus an additional user complaint in npgsql/npgsql#3978). I wouldn't be thrilled to see Sqlite going in the exact opposite direction... |
@KevRitchie thanks for understanding and sorry again you already invested time in the PR. But let us first discuss this as a team to decide on what we want to do here - the above is only my opinion. |
@roji no problem at all. It's all experience 😄 Do you want me keep the PR open for now or close it? |
@KevRitchie let's keep it open for now until we make a decision. |
You can take it!
…On Wed, 6 Oct 2021 at 16:07 Kev Ritchie ***@***.***> wrote:
Hi @bricelam <https://github.com/bricelam>, is this still up for grabs?
@thiagokoster <https://github.com/ThiagoKoster>, do you still want to
take this one?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#18861 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEXK3PTR6FAMMLGFUFUIOADUFSNA3ANCNFSM4JMAY3CA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
One more note for completeness... Just doing a single insensitive list pass is problematic also because an earlier parameter may match insensitively where there's a later parameter that could match sensitively. |
I'm used to all IDbCommand implementations have case insensitive parameter names. This is true for the SqlClient namespace and the System.Data.SQLite package. This feature is very useful, but when I started using the Microsoft.Data.Sqlite package, I got an error:
System.InvalidOperationException: 'Must add values for the following parameters'
To Reproduce
Result:
Additional context
I found the reason of case-sensitivity here: https://github.com/aspnet/EntityFrameworkCore/blob/master/src/Microsoft.Data.Sqlite.Core/SqliteCommand.cs
Line 336:
Equality operator == is case sensitive.
For example, System.Data.SQLite uses this method of compare:
https://github.com/OpenDataSpace/System.Data.SQLite/blob/master/System.Data.SQLite/SQLiteStatement.cs
Line 209:
Microsoft.Data.Sqlite version: 3.1.0-preview2.19525.5
Target framework: .NET 4.8, Xamarin
Operating system: Windows, Android
The text was updated successfully, but these errors were encountered: