From e405c29ce74bf8145f88e4ce33b292474911ce71 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 11 Jan 2016 11:54:29 -0800 Subject: [PATCH] database/sql/driver: clarify DefaultParameterConverter docs Fixes #11489 Change-Id: I887ebac2dcb772e73ee393891c487f694028aaf2 Reviewed-on: https://go-review.googlesource.com/18520 Reviewed-by: Russ Cox --- src/database/sql/driver/types.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/database/sql/driver/types.go b/src/database/sql/driver/types.go index 3305354dfd..bc54784989 100644 --- a/src/database/sql/driver/types.go +++ b/src/database/sql/driver/types.go @@ -200,10 +200,15 @@ func IsScanValue(v interface{}) bool { // ValueConverter that's used when a Stmt doesn't implement // ColumnConverter. // -// DefaultParameterConverter returns the given value directly if -// IsValue(value). Otherwise integer type are converted to -// int64, floats to float64, and strings to []byte. Other types are -// an error. +// DefaultParameterConverter returns its argument directly if +// IsValue(arg). Otherwise, if the argument implements Valuer, its +// Value method is used to return a Value. As a fallback, the provided +// argument's underlying type is used to convert it to a Value: +// underlying integer types are converted to int64, floats to float64, +// and strings to []byte. If the argument is a nil pointer, +// ConvertValue returns a nil Value. If the argument is a non-nil +// pointer, it is dereferenced and ConvertValue is called +// recursively. Other types are an error. var DefaultParameterConverter defaultConverter type defaultConverter struct{}