Skip to content

Commit

Permalink
Fixed #132
Browse files Browse the repository at this point in the history
  • Loading branch information
smtakeda committed Dec 13, 2017
1 parent 067c0d6 commit 4f647d6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func extractTimestamp(srcValue *string) (sec int64, nsec int64, err error) {
func stringToValue(dest *driver.Value, srcColumnMeta execResponseRowType, srcValue *string) error {
if srcValue == nil {
glog.V(3).Infof("snowflake data type: %v, raw value: nil", srcColumnMeta.Type)
dest = nil
*dest = nil
return nil
}
glog.V(3).Infof("snowflake data type: %v, raw value: %v", srcColumnMeta.Type, *srcValue)
Expand Down
20 changes: 20 additions & 0 deletions driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,26 @@ func TestValidateDatabaseParameter(t *testing.T) {
}
}

func TestFetchNil(t *testing.T) {
runTests(t, dsn, func(dbt *DBTest) {
rows := dbt.mustQuery("SELECT * FROM values(3,4),(null, 5) order by 2")
defer rows.Close()
var c1 sql.NullInt64
var c2 sql.NullInt64

var results []sql.NullInt64
for rows.Next() {
err := rows.Scan(&c1, &c2)
if err != nil {
dbt.Fatal(err)
}
results = append(results, c1)
}
if results[1].Valid {
t.Errorf("First element of second row must be nil (NULL). %v", results)
}
})
}
func init() {
if !flag.Parsed() {
flag.Parse()
Expand Down

0 comments on commit 4f647d6

Please sign in to comment.