]> Cypherpunks repositories - gostls13.git/commit
database/sql: make Rows.Scan properly wrap underlying errors
authorTim Möhlmann <muhlemmer@gmail.com>
Thu, 13 Aug 2020 08:56:31 +0000 (11:56 +0300)
committerDaniel Theophanes <kardianos@gmail.com>
Fri, 14 Aug 2020 17:45:39 +0000 (17:45 +0000)
commita20cb4ca5c14ff27bdf16989d450c83b22f156d8
treed9c0d4dada7412c483f0f22213925b2ab7422282
parentd0d6593d1d4e81acd073244f42b6893fa65c99d8
database/sql: make Rows.Scan properly wrap underlying errors

The prior implementation used the format verb %v which unfortunately
improperly wrapped any underlying scanner errors, and we couldn't use
errors.Is nor errors.As. This change fixes that by using the %w verb.

Added a unit to ensure that both error sub string matching works, but
also that errors.Is works as expected.

Fixes #38099

Change-Id: Iea667041dd8081d961246f77f2542330417292dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/248337
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/database/sql/sql.go
src/database/sql/sql_test.go