Skip to content

Commit f53cb31

Browse files
committed
Added support for custom string types.
1 parent 8fefef0 commit f53cb31

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

statement.go

+2
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ func (c converter) ConvertValue(v interface{}) (driver.Value, error) {
157157
return int64(u64), nil
158158
case reflect.Float32, reflect.Float64:
159159
return rv.Float(), nil
160+
case reflect.String:
161+
return rv.String(), nil
160162
}
161163
return nil, fmt.Errorf("unsupported type %T, a %s", v, rv.Kind())
162164
}

statement_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package mysql
2+
3+
import "testing"
4+
5+
type customString string
6+
7+
func TestConvertValueCustomTypes(t *testing.T) {
8+
var cstr customString = "string"
9+
c := converter{}
10+
if _, err := c.ConvertValue(cstr); err != nil {
11+
t.Errorf("custom string type should be valid")
12+
}
13+
}

0 commit comments

Comments
 (0)