mirror of
https://github.com/DATA-DOG/go-sqlmock.git
synced 2025-04-02 21:45:24 +02:00
tests/NullInt: fix Scan from string/[]byte
Do not change the value if Atoi fails
This commit is contained in:
parent
c1f08b2bb1
commit
4f574cddfd
@ -50,13 +50,19 @@ func (ni *NullInt) Scan(value interface{}) (err error) {
|
||||
ni.Integer, ni.Valid = int(v), true
|
||||
return
|
||||
case []byte:
|
||||
ni.Integer, err = strconv.Atoi(string(v))
|
||||
ni.Valid = (err == nil)
|
||||
return
|
||||
n, err := strconv.Atoi(string(v))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ni.Integer, ni.Valid = n, true
|
||||
return nil
|
||||
case string:
|
||||
ni.Integer, err = strconv.Atoi(v)
|
||||
ni.Valid = (err == nil)
|
||||
return
|
||||
n, err := strconv.Atoi(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ni.Integer, ni.Valid = n, true
|
||||
return nil
|
||||
}
|
||||
|
||||
ni.Valid = false
|
||||
|
Loading…
x
Reference in New Issue
Block a user