Beispiel #1
0
func appendDriverValuer(b []byte, v driver.Valuer, quote bool) []byte {
	value, err := v.Value()
	if err != nil {
		panic(err)
	}
	return Append(b, value, quote)
}
Beispiel #2
0
func appendDriverValueRaw(dst []byte, v driver.Valuer) []byte {
	value, err := v.Value()
	if err != nil {
		log.Printf("%#v value failed: %s", v, err)
		return nil
	}
	return appendIfaceRaw(dst, value)
}
Beispiel #3
0
// callValuerValue returns vr.Value(), with one exception:
// If vr.Value is an auto-generated method on a pointer type and the
// pointer is nil, it would panic at runtime in the panicwrap
// method. Treat it like nil instead.
// Issue 8415.
//
// This is so people can implement driver.Value on value types and
// still use nil pointers to those types to mean nil/NULL, just like
// string/*string.
//
// This function is mirrored in the database/sql/driver package.
func callValuerValue(vr driver.Valuer) (v driver.Value, err error) {
	if rv := reflect.ValueOf(vr); rv.Kind() == reflect.Ptr &&
		rv.IsNil() &&
		rv.Type().Elem().Implements(valuerReflectType) {
		return nil, nil
	}
	return vr.Value()
}
Beispiel #4
0
func appendDriverValuer(dst []byte, v driver.Valuer) []byte {
	value, err := v.Value()
	if err != nil {
		log.Printf("%T value failed: %s", v, err)
		return appendNull(dst)
	}
	return appendIface(dst, value)
}
Beispiel #5
0
func appendDriverValuer(b []byte, v driver.Valuer, quote bool) []byte {
	value, err := v.Value()
	if err != nil {
		log.Printf("%T value failed: %s", v, err)
		return appendNull(b, quote)
	}
	return appendIface(b, value, quote)
}