-
Notifications
You must be signed in to change notification settings - Fork 65
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
Feature: Support for DSN flag - sendStringParametersAsUnicode #180
base: main
Are you sure you want to change the base?
Conversation
@microsoft-github-policy-service agree |
@stuartpa @apoorvdeshmukh @shueybubbles can you please check this PR? |
@@ -68,6 +68,9 @@ Other supported formats are listed below. | |||
* `multisubnetfailover` | |||
* `true` (Default) Client attempt to connect to all IPs simultaneously. | |||
* `false` Client attempts to connect to IPs in serial. | |||
* `sendStringParametersAsUnicode` | |||
* `true` (Default) Go default string types sent as `nvarchar`. | |||
* `false` Go default string types sent as `varchar`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shueybubbles it's upto the clients to decide how they want to use Go strings. In the same way other drives like postgres
for Go also works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced it's a good idea for the driver to have such a broad toggle without a more comprehensive fix for mixing string encodings AND having a way for clients to specify the code page of the input.
Note the driver already has a way to designate input parameter strings as varchar to avoid the conversion - you need to use the driver-specific VarChar
Using that type has the benefit of apps being explicit about the desired conversion behavior and being able to mix unicode strings with non-unicode strings in the same connection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shueybubbles the fact that this flag is made available in the official support for sqlserver
is because it makes the applications which work by default with non-unicode strings have lesser chances of failure. With this once and for all we can add this in the connection string, and nowhere explicit type casts are required on top of a string to varchar
, without which any database columns having varchar
as a type, will work the way as expected(for example index queries, etc). We are just trying to adhere to the official documentation of sqlserver
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shueybubbles can you help close this? This has been pending since long. We can have a quick connect on this if needed.
please add some functional tests showing what problem this is solving. |
@shueybubbles problem this PR solves is mentioned here - #40 |
@shueybubbles I agree to your point that it will change for all input parameters that are of the |
@shueybubbles have added test cases for the above please check, also this feature is in accordance with the Official JDBC driver as well. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #180 +/- ##
==========================================
- Coverage 74.72% 74.54% -0.18%
==========================================
Files 32 32
Lines 6298 6341 +43
==========================================
+ Hits 4706 4727 +21
- Misses 1316 1331 +15
- Partials 276 283 +7 ☔ View full report in Codecov by Sentry. |
Your proposed change is quite different from the JDBC model. As the docs for JDBC point out, blindly sending non-unicode data to the server creates a lot of chances for encoding errors due to collation mismatches. If someone just changes the connection string without changing their code, apps that rely on the current behavior to avoid those mismatches will be broken, in ways that can be hard to detect until much later when someone notices data quality issues. |
This is a feature addition for a new DSN flag -
sendStringParametersAsUnicode
which basically allows us to specify if the Go default string types should be sent as UNICODE(if true) or not(if false).Official Support for
sendStringParametersAsUnicode
in JDBC