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
|
// AssignTo dst must always be a pointer
|
||||||
if dstPtr.Kind() != reflect.Ptr {
|
if dstPtr.Kind() != reflect.Ptr {
|
||||||
return errors.Errorf("cannot assign NULL to %T", dst)
|
return &nullAssignmentError{dst: dst}
|
||||||
}
|
}
|
||||||
|
|
||||||
dstVal := dstPtr.Elem()
|
dstVal := dstPtr.Elem()
|
||||||
@@ -380,7 +380,7 @@ func NullAssignTo(dst interface{}) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.Errorf("cannot assign NULL to %T", dst)
|
return &nullAssignmentError{dst: dst}
|
||||||
}
|
}
|
||||||
|
|
||||||
var kindTypes map[reflect.Kind]reflect.Type
|
var kindTypes map[reflect.Kind]reflect.Type
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package pgtype
|
|||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"net"
|
"net"
|
||||||
"reflect"
|
"reflect"
|
||||||
@@ -198,6 +199,14 @@ func (f BinaryEncoderFunc) EncodeBinary(ci *ConnInfo, buf []byte) (newBuf []byte
|
|||||||
var errUndefined = errors.New("cannot encode status undefined")
|
var errUndefined = errors.New("cannot encode status undefined")
|
||||||
var errBadStatus = errors.New("invalid status")
|
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 {
|
type DataType struct {
|
||||||
Value Value
|
Value Value
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user