From 5c0fec018b2a4ce97e510dfc735cf28ec085326b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Mengu=C3=A9?= Date: Thu, 12 Jul 2018 13:57:47 +0200 Subject: [PATCH] tests/NullInt.Scan: add FIXME about removing int{,8,16,32} input support The input of Scan is a driver.Value. Which means the only integer type on input is a int64. But NullInt.Scan also handles int/int8/int16/int32 while that should not be necessary. Unfortunately, sqlmock doesn't enforce strict driver.Value in its implementation and the testsuite (that uses NullInt) relies on this bug. So, this patch just adds a FIXME until sqlmock internals and testsuite are fixed (will maybe require breaking the API). --- stubs_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stubs_test.go b/stubs_test.go index 410d76c..fcd8b29 100644 --- a/stubs_test.go +++ b/stubs_test.go @@ -23,6 +23,11 @@ func (ni *NullInt) Scan(value interface{}) error { switch v := value.(type) { case nil: ni.Integer, ni.Valid = 0, false + + // FIXME int, int8, int16, int32 types are handled here but that should not + // be necessary: only int64 is a driver.Value + // Unfortunately, the sqlmock testsuite currently relies on that because + // sqlmock doesn't properly limits itself internally to pure driver.Value. case int: ni.Integer, ni.Valid = v, true case int8: @@ -31,6 +36,7 @@ func (ni *NullInt) Scan(value interface{}) error { ni.Integer, ni.Valid = int(v), true case int32: ni.Integer, ni.Valid = int(v), true + case int64: const maxUint = ^uint(0) const minUint = 0