-
Notifications
You must be signed in to change notification settings - Fork 150
add tests of #178 #180
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
base: master
Are you sure you want to change the base?
add tests of #178 #180
Conversation
|
@alexbrainman please review this PR, if there is any suggestion please let me know. |
|
@tooilxui your new test fails on my Linux computer Alex |
|
@alexbrainman I had change column type to nvarchar and test passed. $ go test -run ^TestMSSQLIssue178$ github.com/alexbrainman/odbc
ok github.com/alexbrainman/odbc 0.617sgo version: $ go version
go version go1.18.3 windows/amd64sql server info: |
|
@alexbrainman I had try another way to test, but in GBK test still failed, could you help me figure it out? (I think BIG5 case is correct) |
|
@tooilxui sorry but I don't have time to debug this. And I don't speak Chinese. And I am unfamiliar with language specific features in MS SQL. So I don't know whether you test is correct or not. Alex |
tooilxui
left a comment
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.
@alexbrainman test of big5 and gbk are both work now. please review again.
| // query inserted poem and compare with testCase.poem | ||
| var rowPoem string | ||
| if err = db.QueryRow( | ||
| "select cast(poem as nvarchar(max)) from dbo.temp", |
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.
@alexbrainman
It seems that sql server automatically detects the client locale and converts the query value to the client charset (like following picture), so I decided to convert the query value to nvarchar to ensure the value is in unicode encoding. The test compares inserted value (testCase.poem) and query value are both in unicode.
I checked every single byte of query value, and characters not compatible with big5 (yellow part) are all turns to 3F (question mark / ?). my client locale is zh_tw.big5.

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.
@alexbrainman I found this article on stackflow which explains how client charset works on sqlserver. just match with my guess.
|
@alexbrainman hello,do you have time to take a look? |
|
Your test succeeds if I revert the fix: Your test should fail instead. Also you test cannot be run second time. If I run your test second time, this happens: Alex |
|
Isn't your test supposed to be responsible for setting everything to demonstrate the bug in existing code?
I run this Makefile command Line 19 in 9c9a2e6
Thank you. Alex |
this RP contains huiyu's contribution in #179, and add test for #178