diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2013-02-21 10:43:00 -0800 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2013-02-21 10:43:00 -0800 |
| commit | bca3f5fca030599c41523570a3be9527448e73a9 (patch) | |
| tree | b288e4dc398094e46d360fdc40a37b4fbcd23cad /src/pkg/database/sql/sql_test.go | |
| parent | 5833c96b0a3b1e77b787ee9b908456a7334f7821 (diff) | |
| download | go-bca3f5fca030599c41523570a3be9527448e73a9.tar.xz | |
database/sql: check for nil Scan pointers
Return nice errors and don't panic.
Fixes #4859
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7383046
Diffstat (limited to 'src/pkg/database/sql/sql_test.go')
| -rw-r--r-- | src/pkg/database/sql/sql_test.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/pkg/database/sql/sql_test.go b/src/pkg/database/sql/sql_test.go index 74ba8e0ce7..53b229600d 100644 --- a/src/pkg/database/sql/sql_test.go +++ b/src/pkg/database/sql/sql_test.go @@ -696,3 +696,15 @@ func nullTestRun(t *testing.T, spec nullTestSpec) { } } } + +// golang.org/issue/4859 +func TestQueryRowNilScanDest(t *testing.T) { + db := newTestDB(t, "people") + defer closeDB(t, db) + var name *string // nil pointer + err := db.QueryRow("SELECT|people|name|").Scan(name) + want := "sql: Scan error on column index 0: destination pointer is nil" + if err == nil || err.Error() != want { + t.Errorf("error = %q; want %q", err.Error(), want) + } +} |
