-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
database/sql: sql argument counts are off by one when reporting an error #15676
Comments
I suspect any changes we make at this point are just going to make things even more confusing, unfortunately. Would dropping the "#" prefix make you less likely to think they're 1-based? /cc @bradfitz ? |
I'm of the opinion we should ensure all parameters are referenced by ordinal, not index. |
@kardianos, you mean you advocate for a change, rather than documenting the status quo? |
Yes, I would change the message to ensure all parameters match the ordinal position. Simply being SQL is reason enough to think they are 1-based references (ordinal not index). |
Sure. We can change it if everybody agrees. Should we preface them all by '$' then? Is that more clear? |
CL https://golang.org/cl/31262 mentions this issue. |
How about keeping |
@lpar What do you think of the CL https://golang.org/cl/31262 ? I hope no one is trying to parse the error message mechanically, but if they are, I can include it in a general announcement in a week or two. |
I think the improved message would at least have eliminated my confusion after the fact. |
I know this is pretty trivial, but when reporting an error the sql package seems to report arguments by counting them starting at zero.
Since SQL arguments are generally numbered from 1 -- and indeed, for PostgreSQL they are numbered $1, $2, $3... in the SQL itself -- this confused me.
e.g. sql: converting Exec argument #3's type: unsupported type main.Date, a struct
It was actually argument #4 ($4 in the SQL statement).
go version go1.6.2 linux/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/meta/go/tecdocs"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
The text was updated successfully, but these errors were encountered: