diff options
Diffstat (limited to 'libgo/go/database/sql/driver')
-rw-r--r-- | libgo/go/database/sql/driver/types.go | 7 | ||||
-rw-r--r-- | libgo/go/database/sql/driver/types_test.go | 4 |
2 files changed, 11 insertions, 0 deletions
diff --git a/libgo/go/database/sql/driver/types.go b/libgo/go/database/sql/driver/types.go index f383885..ce3c943 100644 --- a/libgo/go/database/sql/driver/types.go +++ b/libgo/go/database/sql/driver/types.go @@ -248,6 +248,13 @@ func (defaultConverter) ConvertValue(v interface{}) (interface{}, error) { rv := reflect.ValueOf(v) switch rv.Kind() { + case reflect.Ptr: + // indirect pointers + if rv.IsNil() { + return nil, nil + } else { + return defaultConverter{}.ConvertValue(rv.Elem().Interface()) + } case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return rv.Int(), nil case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32: diff --git a/libgo/go/database/sql/driver/types_test.go b/libgo/go/database/sql/driver/types_test.go index 966bc6b..ab82bca 100644 --- a/libgo/go/database/sql/driver/types_test.go +++ b/libgo/go/database/sql/driver/types_test.go @@ -18,6 +18,7 @@ type valueConverterTest struct { } var now = time.Now() +var answer int64 = 42 var valueConverterTests = []valueConverterTest{ {Bool, "true", true, ""}, @@ -37,6 +38,9 @@ var valueConverterTests = []valueConverterTest{ {c: Bool, in: "foo", err: "sql/driver: couldn't convert \"foo\" into type bool"}, {c: Bool, in: 2, err: "sql/driver: couldn't convert 2 into type bool"}, {DefaultParameterConverter, now, now, ""}, + {DefaultParameterConverter, (*int64)(nil), nil, ""}, + {DefaultParameterConverter, &answer, answer, ""}, + {DefaultParameterConverter, &now, now, ""}, } func TestValueConverters(t *testing.T) { |