Skip to content

Commit

Permalink
Add defensive check to workaround obscure bug with nil parent (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop authored Feb 11, 2021
1 parent 56a600c commit 899dcc4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,13 @@ func (s wStmt) Close() (err error) {
}

func (s wStmt) NumInput() int {
// NumInput may also return -1, if the driver doesn't know
// its number of placeholders. In that case, the sql package
// will not sanity check Exec or Query argument counts.
if s.parent == nil {
return -1
}

return s.parent.NumInput()
}

Expand Down

0 comments on commit 899dcc4

Please sign in to comment.