snowflake-connector-net
snowflake-connector-net copied to clipboard
SNOW-970857: Parameter DbType should track explicit assignment rather than hard default to AnsiString
Currently DbType
is a basic auto-implemented property: https://github.com/snowflakedb/snowflake-connector-net/blob/master/Snowflake.Data/Client/SnowflakeDbParameter.cs#L37
This causes problems because it defaults to AnsiString
(value zero) (because)
To complicate things: multiple providers have types where setting the DbType
is actively discouraged, because they will use additional types internally when assigned. This means that provider-agnostic tools (think "Dapper") actively choose not to set this property in those cases, which causes problems.
The way most providers do this is to track explicit assignment; if it has never actively been assigned a value, then the get
value is inferred from the .Value
(or other mechanisms).
Examples:
- https://github.com/npgsql/npgsql/blob/main/src/Npgsql/NpgsqlParameter.cs#L314
- https://github.com/dotnet/SqlClient/blob/d30d9d107eca0f11b735a550aa187e57167858c9/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs#L462
I suggest this provider should do something similar, to avoid the problem where if DbType
is not set, things are sent as AnsiString
hi and thank you for raising this issue and especially for the detailed description of how this would be useful ! we'll take a look at this enhancement request.
@sfc-gh-dszmolka please prioritize this, we're forced to use no longer supported versions (1.x) due to this. I'd classify this as a bug, as a matter of fact.
Sure - let us sync internally and the driver team can decide what's the best to move forward with this issue. Thank you for bearing with us !
PR in review https://github.com/snowflakedb/snowflake-connector-net/pull/889
PR merged and fix will be part of the 2024 April release, towards the end of month
Will update this thread once more information is known about the next upcoming major release of the .NET driver which will carry this fix.
edit: confirming with Product team; release should be available by mid-July 2024
fix released with Snowflake .NET driver version v4.0.0 in July 2024