From 2177bfb343c4950be88536044bb38c90f05ad3ed Mon Sep 17 00:00:00 2001 From: Daniel Theophanes Date: Fri, 26 Apr 2019 11:46:26 -0700 Subject: database/sql: add NullInt32 It is common for database integers to be represented as int32 internally. Although NullInt64 is already defined, this should remove some type casts and make working with those eaiser. For #31231 Change-Id: Ia0c37ecef035fee0734c1d1fb6f58aef6905cf5e Reviewed-on: https://go-review.googlesource.com/c/go/+/174178 Run-TryBot: Daniel Theophanes TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/database/sql/sql_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/database/sql/sql_test.go') diff --git a/src/database/sql/sql_test.go b/src/database/sql/sql_test.go index cc30ad3daa..260374d413 100644 --- a/src/database/sql/sql_test.go +++ b/src/database/sql/sql_test.go @@ -131,6 +131,7 @@ func TestDriverPanic(t *testing.T) { } func exec(t testing.TB, db *DB, query string, args ...interface{}) { + t.Helper() _, err := db.Exec(query, args...) if err != nil { t.Fatalf("Exec of %q: %v", query, err) @@ -1671,6 +1672,18 @@ func TestNullInt64Param(t *testing.T) { nullTestRun(t, spec) } +func TestNullInt32Param(t *testing.T) { + spec := nullTestSpec{"nullint32", "int32", [6]nullTestRow{ + {NullInt32{31, true}, 1, NullInt32{31, true}}, + {NullInt32{-22, false}, 1, NullInt32{0, false}}, + {22, 1, NullInt32{22, true}}, + {NullInt32{33, true}, 1, NullInt32{33, true}}, + {NullInt32{222, false}, 1, NullInt32{0, false}}, + {0, NullInt32{31, false}, nil}, + }} + nullTestRun(t, spec) +} + func TestNullFloat64Param(t *testing.T) { spec := nullTestSpec{"nullfloat64", "float64", [6]nullTestRow{ {NullFloat64{31.2, true}, 1, NullFloat64{31.2, true}}, -- cgit v1.3