diff --git a/AUTHORS b/AUTHORS index ac36be9a7..ca6a1daeb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -18,6 +18,7 @@ Asta Xie Bulat Gaifullin Carlos Nieto Chris Moos +Daniel Montoya Daniel Nichter Daniƫl van Eeden Dave Protasowski diff --git a/statement.go b/statement.go index ae223507f..628174b64 100644 --- a/statement.go +++ b/statement.go @@ -157,6 +157,8 @@ func (c converter) ConvertValue(v interface{}) (driver.Value, error) { return int64(u64), nil case reflect.Float32, reflect.Float64: return rv.Float(), nil + case reflect.String: + return rv.String(), nil } return nil, fmt.Errorf("unsupported type %T, a %s", v, rv.Kind()) } diff --git a/statement_test.go b/statement_test.go new file mode 100644 index 000000000..8de4a8b26 --- /dev/null +++ b/statement_test.go @@ -0,0 +1,21 @@ +// Go MySQL Driver - A MySQL-Driver for Go's database/sql package +// +// Copyright 2017 The Go-MySQL-Driver Authors. All rights reserved. +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this file, +// You can obtain one at http://mozilla.org/MPL/2.0/. + +package mysql + +import "testing" + +type customString string + +func TestConvertValueCustomTypes(t *testing.T) { + var cstr customString = "string" + c := converter{} + if _, err := c.ConvertValue(cstr); err != nil { + t.Errorf("custom string type should be valid") + } +}