snowflake-connector-net icon indicating copy to clipboard operation
snowflake-connector-net copied to clipboard

SNOW-295947: Data Conversion Culture issue

Open clegendre opened this issue 3 years ago • 0 comments

Issue description

The data returned by the Snowflake API used by this driver is string-based. So, internally, there are string-to-type conversions (performed by SFDataConverter in the codebase). The problem is that this converter forces the InvariantCulture of the current thread. This is a very bad practice and does not works well when using async/await API, it will force client code to use ConfigureAwait(true) to capture the logical context between context switches. This PR (#246) changes how the SFDataConverter converts the data, and should be merged or you should get inspiration on it.

Error log

      "ClassName": "System.Data.DataException",
      "Message": "Error parsing column 11 (COST=1 - Int64)",
      "Data": {},
      "InnerException": {
        "ClassName": "System.ArgumentException",
        "Message": "0.16 is not a valid value for Double.",
        "Data": {},
        "InnerException": {
          "ClassName": "System.FormatException",
          "Message": "Input string was not in a correct format.",

This error is raised because the application runs with a default FR-fr language (OS language), and decimal types are not handled in the same way in the FR culture.

Configuration

Driver version: 1.2.0

Dotnet framework and version: netcore3.1 / net5.0

Server version: 5.6.5

Client OS: Windows 10

clegendre avatar Mar 05 '21 13:03 clegendre