2
0

Extract nullAssignmentError

This commit is contained in:
Jack Christensen
2020-05-10 12:28:47 -05:00
parent 52729c1b77
commit a71c179ce3
2 changed files with 11 additions and 2 deletions
+2 -2
View File
@@ -369,7 +369,7 @@ func NullAssignTo(dst interface{}) error {
// AssignTo dst must always be a pointer
if dstPtr.Kind() != reflect.Ptr {
return errors.Errorf("cannot assign NULL to %T", dst)
return &nullAssignmentError{dst: dst}
}
dstVal := dstPtr.Elem()
@@ -380,7 +380,7 @@ func NullAssignTo(dst interface{}) error {
return nil
}
return errors.Errorf("cannot assign NULL to %T", dst)
return &nullAssignmentError{dst: dst}
}
var kindTypes map[reflect.Kind]reflect.Type
+9
View File
@@ -3,6 +3,7 @@ package pgtype
import (
"database/sql"
"encoding/binary"
"fmt"
"math"
"net"
"reflect"
@@ -198,6 +199,14 @@ func (f BinaryEncoderFunc) EncodeBinary(ci *ConnInfo, buf []byte) (newBuf []byte
var errUndefined = errors.New("cannot encode status undefined")
var errBadStatus = errors.New("invalid status")
type nullAssignmentError struct {
dst interface{}
}
func (e *nullAssignmentError) Error() string {
return fmt.Sprintf("cannot assign NULL to %T", e.dst)
}
type DataType struct {
Value Value