Open flimzy opened 2 weeks ago
Change https://go.dev/cl/597115 mentions this issue: database/sql: Don't skip default argument conversion for ColumnConverters and unknown input count
@bradfitz @kardianos per owners.
Thanks for sending a CL --
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Go version
go version go1.22.0 linux/amd64
Output of
go env
in your module/workspace:What did you do?
I wrote a
database/sql
driver that implements the optionalColumnConverter
interface for prepared statements, and for whichNumInputs()
returns -1.Technically, I wrote a
databse/sql
proxy driver, for the purpose of adding hooks to DB operations, to aide in debugging. See https://gitlab.com/flimzy/errsqlBut using this library with
modernc.org/sqlite
is what triggered the buggy behavior.modernc.org/sqlite
itself does not implement theColumnConverter
interface, but it does return -1 forNumInputs
. Because the proxy driver does implementColumnConverter
(because it must implement it for all drivers it proxies, or none), it triggers the observed behavior.What did you see happen?
The
ColumnConverter
method is never called, leading to the following error from sqlite:What did you expect to see?
I expected that
ColumnConverter
would be called.Analysis & Possible Fix
This line appears to be the culprit:
c.want
is set to the return value fromstmt.NumInputs()
, so is-1
in this case. The method containing this code is only executed whenColumnConverter
is implemented, as we can see here.I believe the solution is to change the above mentioned line to: