darkwood001 / odbc

Automatically exported from code.google.com/p/odbc
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

empty string in MSSQL NVARCHAR column cause func (r *Row) Scan() to fail #42

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. append the attached go code to code.google.com\p\odbc\mssql_test.go
2. run go test

What is the expected output? What do you see instead?

 expect the test to pass, but got the following:

 mssql_test.go:1254: sql: Scan error on column index 0: unsupported driver -> Scan pair: <nil> -> *string

What version of the product are you using? On what operating system?
go version go1.2 windows/amd64
sql server version:
Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64)   Apr  2 2010 15:48:46  
 Copyright (c) Microsoft Corporation  Enterprise Edition (64-bit) on Windows NT 
6.1 <X64> (Build 7601: Service Pack 1) 

Please provide any additional information below.

1) the issue exists when column type is NVARCHAR. it works fine when column 
type is VARCHAR
2) inside MSSQL, go string "" is stored as SQL server  '' , so it should be 
able to be read back as string
3) for MS SQL, varchar empty string '' is the same as nvarchar empty string 
N''. this can be proved as SQL below:
select case when ''=N'' then 'equal' else 'not equal' end

4) this issue is critical as NVARCHAR is way more widely used than VARCHAR due 
to VARCHAR does not support unicode well.

your reply is greatly appreciated

Jusong Chen

Original issue reported on code.google.com by jusong.c...@gmail.com on 8 May 2014 at 10:26

Attachments:

GoogleCodeExporter commented 9 years ago
jusong.chen,

Are you using latest version. What does your "hg id" command say? Thank you.

Alex

Original comment by alex.bra...@gmail.com on 9 May 2014 at 12:19

GoogleCodeExporter commented 9 years ago
Alex,
see command output below:

C:\Go\src\code.google.com\p\odbc>hg id
79ae99114308+ tip

Jusong

Original comment by jusong.c...@gmail.com on 9 May 2014 at 12:53

GoogleCodeExporter commented 9 years ago
You are missing 2 latest changes. Please update your repo (hg pull -u) and try 
again. Latest version is a8ac5d333051. Thank you.

Alex

Original comment by alex.bra...@gmail.com on 9 May 2014 at 1:01

GoogleCodeExporter commented 9 years ago
Awesome! it works now! thank you so mmuch.

Original comment by jusong.c...@gmail.com on 9 May 2014 at 1:36

GoogleCodeExporter commented 9 years ago

Original comment by alex.bra...@gmail.com on 9 May 2014 at 1:38