diff --git a/AUTHORS b/AUTHORS index c405b8912..1ace1fa45 100644 --- a/AUTHORS +++ b/AUTHORS @@ -71,6 +71,7 @@ Zhenye Xie # Organizations Barracuda Networks, Inc. +Counting Ltd. Google Inc. Keybase Inc. Pivotal Inc. diff --git a/connection_go18.go b/connection_go18.go index 1306b70b7..65cc63ef2 100644 --- a/connection_go18.go +++ b/connection_go18.go @@ -197,6 +197,10 @@ func (mc *mysqlConn) startWatcher() { } func (mc *mysqlConn) CheckNamedValue(nv *driver.NamedValue) (err error) { - nv.Value, err = converter{}.ConvertValue(nv.Value) + value, err := converter{}.ConvertValue(nv.Value) + if err != nil { + return driver.ErrSkip + } + nv.Value = value return } diff --git a/driver_test.go b/driver_test.go index f6965b191..392e752a3 100644 --- a/driver_test.go +++ b/driver_test.go @@ -499,6 +499,36 @@ func TestString(t *testing.T) { }) } +type testValuer struct { + value string +} + +func (tv testValuer) Value() (driver.Value, error) { + return tv.value, nil +} + +func TestValuer(t *testing.T) { + runTests(t, dsn, func(dbt *DBTest) { + in := testValuer{"a_value"} + var out string + var rows *sql.Rows + + dbt.mustExec("CREATE TABLE test (value VARCHAR(255)) CHARACTER SET utf8") + dbt.mustExec("INSERT INTO test VALUES (?)", in) + rows = dbt.mustQuery("SELECT value FROM test") + if rows.Next() { + rows.Scan(&out) + if in.value != out { + dbt.Errorf("Valuer: %v != %s", in, out) + } + } else { + dbt.Errorf("Valuer: no data") + } + + dbt.mustExec("DROP TABLE IF EXISTS test") + }) +} + type timeTests struct { dbtype string tlayout string