Skip to content

Commit e405c29

Browse files
committed
database/sql/driver: clarify DefaultParameterConverter docs
Fixes #11489 Change-Id: I887ebac2dcb772e73ee393891c487f694028aaf2 Reviewed-on: https://go-review.googlesource.com/18520 Reviewed-by: Russ Cox <[email protected]>
1 parent 70ee525 commit e405c29

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/database/sql/driver/types.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,15 @@ func IsScanValue(v interface{}) bool {
200200
// ValueConverter that's used when a Stmt doesn't implement
201201
// ColumnConverter.
202202
//
203-
// DefaultParameterConverter returns the given value directly if
204-
// IsValue(value). Otherwise integer type are converted to
205-
// int64, floats to float64, and strings to []byte. Other types are
206-
// an error.
203+
// DefaultParameterConverter returns its argument directly if
204+
// IsValue(arg). Otherwise, if the argument implements Valuer, its
205+
// Value method is used to return a Value. As a fallback, the provided
206+
// argument's underlying type is used to convert it to a Value:
207+
// underlying integer types are converted to int64, floats to float64,
208+
// and strings to []byte. If the argument is a nil pointer,
209+
// ConvertValue returns a nil Value. If the argument is a non-nil
210+
// pointer, it is dereferenced and ConvertValue is called
211+
// recursively. Other types are an error.
207212
var DefaultParameterConverter defaultConverter
208213

209214
type defaultConverter struct{}

0 commit comments

Comments
 (0)