fixer-m / snowflake-db-net-client

Snowflake .NET Client
Apache License 2.0
51 stars 14 forks source link

Handling Array (Variant) objects from Snowflake #4

Closed vostruk closed 3 years ago

vostruk commented 3 years ago

Hi, First of all thanks for developing this library, it is much better than default one in my opinion!

I was testing it and tried to query Snowflake ARRAY type into C# List, but received

System.Text.Json.JsonException '0x0A' is invalid within a JSON string. The string should be correctly escaped.

Is there a way to overcome this using Options or the fix should be added to Mapper?

fixer-m commented 3 years ago

Thank you for your bug report!

I have just fixed this bug in Mapper, now it should properly map array, variant and object data types. This will be included in the next release of a NuGet package soon - I just need some more time to do some additional tests. But you already can use fixed version directly from master branch.

fixer-m commented 3 years ago

@vostruk, I've included this fix into latest NuGet release - Snowflake.Client 0.3.1. Can you please try this version and approve, that array mapping now works as should?

vostruk commented 3 years ago

@fixer-m, yes array mapping works well now. Thanks a lot for solving that!

Also I found another bug related to it (could open a new issue if needed) - when using complex objects (like List) in sqlParams the error is thrown. For example performing an insert with something like:

await snowflakeClient.ExecuteAsync("INSERT INTO EMPLOYEES (EmploymentsList) VALUES (:EmploymentsList);", new { EmploymentsList = new List<string> {"Programmer"} });

Causes an error in SnowflakeClient.cs like 137 (BuildQueryRequest method)

I understand where this may come from, since filtering on such objects may not be needed. But inserts of complex objects is quite common thing, at least in my case. Would be great if we can solve this problem too.

fixer-m commented 3 years ago

@vostruk Great! Can you please create a new separate issue for this? This is completely unrelated to original mapping issue, new one is related to Parameter Binding feature. Then I can close this bug.

vostruk commented 3 years ago

Done, https://github.com/fixer-m/snowflake-db-net-client/issues/5 let's close this one. Thanks for solving!