Skip to content

Dapper.Contrib does not pass Turkey Test #73

Closed as not planned
Closed as not planned

Description

@yusufozturk

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.

Activity

  1. rhubley commented on May 2, 2018

    @rhubley

    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.

  2. yusufozturk commented on May 2, 2018

    @yusufozturk
    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.

  3. canertosuner commented on May 3, 2018

    @canertosuner

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

  4. rhubley commented on May 3, 2018

    @rhubley

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

  5. Adondriel commented on May 21, 2018

    @Adondriel

    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

  6. transferred this issue fromDapperLib/Dapperon May 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions