Extract nullAssignmentError
This commit is contained in:
+2
-2
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user