mirror of
https://github.com/DATA-DOG/go-sqlmock.git
synced 2025-03-23 21:09:19 +02:00
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).
This commit is contained in:
parent
87bbc72050
commit
5c0fec018b
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user