Skip to content
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

Dapper.Contrib does not pass Turkey Test #73

Open
yusufozturk opened this issue Apr 27, 2018 · 5 comments
Open

Dapper.Contrib does not pass Turkey Test #73

yusufozturk opened this issue Apr 27, 2018 · 5 comments

Comments

@yusufozturk
Copy link

In the following code:

https://github.com/StackExchange/Dapper/blob/master/Dapper.Contrib/SqlMapperExtensions.cs#L117

There is a string.equals operation to find "id" in the all properties which fails in Turkey test. So operations are getting failed in all Turkish locale servers. "id" is "İD" or "ıd" in Turkish, so basically it fails for the "ID" column.

We have a custom "ToLower" extension which handles this issue. I don't know if there is another easy solution to work around.

@rhubley
Copy link

rhubley commented May 2, 2018

If you changed it to compare to "ID" instead of "id" does it work for you? Apparently ToUpper works better for Turkey, don't know if it fails for other cultures though.

@yusufozturk
Copy link
Author

@rhubley

ToUpper can make it "İD", so it will fail again :)

I think the best way is adding culture to string.equal operation. For now, we wrote a custom convert method to change ıd to id, İD to ID etc.

@canertosuner
Copy link

@yusufozturk
Could you share your ext. method ? or what does it exactly do for it ?

@rhubley
Copy link

rhubley commented May 3, 2018

Setting a culture is tricky, you would need your code and Database to share the same culture which might not always be the case.

@Adondriel
Copy link

Adondriel commented May 21, 2018

We should probably address this by using whatever locale is used in the model object, by changing the hardcoded "id" to grabbing the variable name from the object itself. This would mean that if they define the model in turkish(is that the name of the language?) that should give us the correct variable to query against. (grabbed via the [Key] attribute, of course)

Edit: NVM, this is not needed. This is an internal thing. We are using the wrong method for comparing them, I think.
see reference: https://msdn.microsoft.com/en-us/library/system.stringcomparer.currentcultureignorecase(v=vs.110).aspx

@NickCraver NickCraver transferred this issue from DapperLib/Dapper May 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants