]> Cypherpunks repositories - gostls13.git/commit
database/sql: allow drivers to support custom arg types
authorDaniel Theophanes <kardianos@gmail.com>
Thu, 23 Mar 2017 20:17:59 +0000 (13:17 -0700)
committerDaniel Theophanes <kardianos@gmail.com>
Thu, 18 May 2017 22:22:31 +0000 (22:22 +0000)
commita9bf3b2e19920f6f516bc2e0211ae2e2f7ce395c
tree3ef9485c394a6713242e556086237a09d6cd92d4
parent9044cb04f2c0379e907d0b2e944043e81888033e
database/sql: allow drivers to support custom arg types

Previously all arguments were passed through driver.IsValid.
This checked arguments against a few fundamental go types and
prevented others from being passed in as arguments.

The new interface driver.NamedValueChecker may be implemented
by both driver.Stmt and driver.Conn. This allows
this new interface to completely supersede the
driver.ColumnConverter interface as it can be used for
checking arguments known to a prepared statement and
arbitrary query arguments. The NamedValueChecker may be
skipped with driver.ErrSkip after all special cases are
exhausted to use the default argument converter.

In addition if driver.ErrRemoveArgument is returned
the argument will not be passed to the query at all,
useful for passing in driver specific per-query options.

Add a canonical Out argument wrapper to be passed
to OUTPUT parameters. This will unify checks that need to
be written in the NameValueChecker.

The statement number check is also moved to the argument
converter so the NamedValueChecker may remove arguments
passed to the query.

Fixes #13567
Fixes #18079
Updates #18417
Updates #17834
Updates #16235
Updates #13067
Updates #19797

Change-Id: I89088bd9cca4596a48bba37bfd20d987453ef237
Reviewed-on: https://go-review.googlesource.com/38533
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/database/sql/convert.go
src/database/sql/convert_test.go
src/database/sql/driver/driver.go
src/database/sql/fakedb_test.go
src/database/sql/sql.go
src/database/sql/sql_test.go