示例#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)
}
示例#2
0
文件: append.go 项目: uruddarraju/pg
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)
}
示例#3
0
文件: convert.go 项目: oshimaya/go
// 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()
}
示例#4
0
文件: append.go 项目: lcplj123/pg
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)
}
示例#5
0
文件: append.go 项目: anmic/pg
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)
}