Skip to content

Commit 5e3001f

Browse files
committed
Only implement CheckNamedValue for go1.8+
1 parent 8d49f7b commit 5e3001f

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

connection.go

-5
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,3 @@ func (mc *mysqlConn) finish() {
459459
case <-mc.closech:
460460
}
461461
}
462-
463-
func (mc *mysqlConn) CheckNamedValue(nv *driver.NamedValue) (err error) {
464-
nv.Value, err = converter{}.ConvertValue(nv.Value)
465-
return
466-
}

connection_go18.go

+5
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,8 @@ func (mc *mysqlConn) startWatcher() {
195195
}
196196
}()
197197
}
198+
199+
func (mc *mysqlConn) CheckNamedValue(nv *driver.NamedValue) (err error) {
200+
nv.Value, err = converter{}.ConvertValue(nv.Value)
201+
return
202+
}

connection_go18_test.go

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Go MySQL Driver - A MySQL-Driver for Go's database/sql package
2+
//
3+
// Copyright 2017 The Go-MySQL-Driver Authors. All rights reserved.
4+
//
5+
// This Source Code Form is subject to the terms of the Mozilla Public
6+
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
7+
// You can obtain one at http://mozilla.org/MPL/2.0/.
8+
9+
// +build go1.8
10+
11+
package mysql
12+
13+
import (
14+
"database/sql/driver"
15+
"testing"
16+
)
17+
18+
func TestCheckNamedValue(t *testing.T) {
19+
value := driver.NamedValue{Value: ^uint64(0)}
20+
x := &mysqlConn{}
21+
err := x.CheckNamedValue(&value)
22+
23+
if err != nil {
24+
t.Fatal("High-bit set uint64 not supported", err)
25+
}
26+
27+
if value.Value != "18446744073709551615" {
28+
t.Fatal("High-bit set uint64 not supported", value.Value)
29+
}
30+
}

0 commit comments

Comments
 (0)