Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions queries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ func TestParams(t *testing.T) {
"",
[]byte{1, 2, 3},
[]byte{},
float32(1.12313),
float64(1.12313554),
true,
false,
Expand Down Expand Up @@ -543,21 +544,22 @@ func TestParams(t *testing.T) {
}
case time.Time:
same = decodedval.UTC() == val
case int64:
switch intVal := val.(type) {
default:
rettype := reflect.TypeOf(retval)
switch origval := val.(type) {
case int8:
same = rettype.Kind() == reflect.Int64 && decodedval == int64(origval)
case int16:
same = decodedval == int64(intVal)
same = rettype.Kind() == reflect.Int64 && decodedval == int64(origval)
case int32:
same = decodedval == int64(intVal)
case int8:
same = decodedval == int64(intVal)
same = rettype.Kind() == reflect.Int64 && decodedval == int64(origval)
case int:
same = decodedval == int64(intVal)
same = rettype.Kind() == reflect.Int64 && decodedval == int64(origval)
case float32:
same = rettype.Kind() == reflect.Float64 && decodedval == float64(origval)
default:
same = retval == val
}
default:
same = retval == val
}
if !same {
t.Error("Value don't match", retval, val)
Expand Down
10 changes: 5 additions & 5 deletions types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import (

func TestMakeGoLangScanType(t *testing.T) {
if (reflect.TypeOf(int64(0)) != makeGoLangScanType(typeInfo{TypeId: typeInt8})) {
t.Errorf("invalid type returned for typeDateTime")
t.Errorf("invalid type returned for typeInt8")
}
if (reflect.TypeOf(float64(0)) != makeGoLangScanType(typeInfo{TypeId: typeFlt4})) {
t.Errorf("invalid type returned for typeDateTime")
t.Errorf("invalid type returned for typeFlt4")
}
if (reflect.TypeOf(float64(0)) != makeGoLangScanType(typeInfo{TypeId: typeFlt8})) {
t.Errorf("invalid type returned for typeDateTime")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love those copy/paste bugs

t.Errorf("invalid type returned for typeFlt8")
}
if (reflect.TypeOf("") != makeGoLangScanType(typeInfo{TypeId: typeVarChar})) {
t.Errorf("invalid type returned for typeDateTime")
t.Errorf("invalid type returned for typeVarChar")
}
if (reflect.TypeOf(time.Time{}) != makeGoLangScanType(typeInfo{TypeId: typeDateTime})) {
t.Errorf("invalid type returned for typeDateTime")
Expand All @@ -38,7 +38,7 @@ func TestMakeGoLangScanType(t *testing.T) {
t.Errorf("invalid type returned for typeIntN")
}
if (reflect.TypeOf([]byte{}) != makeGoLangScanType(typeInfo{TypeId: typeMoney, Size: 8})) {
t.Errorf("invalid type returned for typeIntN")
t.Errorf("invalid type returned for typeMoney")
}
}

Expand Down