jackc / pgx

PostgreSQL driver and toolkit for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Panic in prepared statesment

maksymnevajdev opened this issue · comments

Describe the bug
If prepared arguments in sql string started with 0 - finish with panic(out of range -1 )
https://github.com/jackc/pgx/blob/master/internal/sanitize/sanitize.go:41
To Reproduce
Select * from table where id = $0
Fix

add
if argIdx < 0 { return "", fmt.Errorf("first sql argument must be > 0") }
in
https://github.com/jackc/pgx/blob/master/internal/sanitize/sanitize.go:38