// Value implements the driver Valuer interface.
348768
func (n NullInt32) Value() (driver.Value, error) {
	if n.Valid {
		return n.Int32, nil
	}
	return nil, nil
}
181978
func (a StringArray) Value() (driver.Value, error) {
	if a == nil {
		return nil, nil
	}

	if n := len(a); n > 0 {
		// There will be at least two curly brackets, 2*N bytes of quotes,
		// and N-1 bytes of delimiters.
		b := make([]byte, 1, 1+3*n)
		b[0] = '{'

		b = appendArrayQuotedBytes(b, []byte(a[0]))
		for i := 1; i < n; i++ {
			b = append(b, ',')
			b = appendArrayQuotedBytes(b, []byte(a[i]))
		}

		return string(append(b, '}')), nil
	}

	return "{}", nil
}
570665
func (j JSON) Value() (driver.Value, error) {
	if len(j.RawMessage) == 0 {
		return nil, nil
	}
	return j.MarshalJSON()
}
234782
func (t TimeDefLocal) Value() (driver.Value, error) {
	return t.T.Local(), nil
}
662721
func (src *TimestampArray) Value() (driver.Value, error) {
	buf, err := src.EncodeText(nil, nil)
	if err != nil {
		return nil, err
	}
	if buf == nil {
		return nil, nil
	}

	return string(buf), nil
}
1187539
func (sa StringArray) Value() (driver.Value, error) {
	if !sa.Valid {
		return nil, nil
	}

	return StringArrayValue(sa.StringArray)
}
645979
func (src *Numeric) Value() (driver.Value, error) {
	switch src.Status {
	case pgtype.Present:
		return src.Decimal.Value()
	case pgtype.Null:
		return nil, nil
	default:
		return nil, errUndefined
	}
}
1007773
func (j JSONText) Value() (driver.Value, error) {
	var m json.RawMessage
	var err = j.Unmarshal(&m)
	if err != nil {
		return []byte{}, err
	}
	return []byte(j), nil
}
924874
func (src *Date) Value() (driver.Value, error) {
	switch src.Status {
	case Present:
		if src.InfinityModifier != None {
			return src.InfinityModifier.String(), nil
		}
		return src.Time, nil
	case Null:
		return nil, nil
	default:
		return nil, errUndefined
	}
}
811622
func (a StringArray) Value() (driver.Value, error) {
	if a == nil {
		return nil, nil
	}

	res := make([]string, len(a))
	for i, e := range a {
		r := e
		r = strings.Replace(r, `\`, `\\`, -1)
		r = strings.Replace(r, `"`, `\"`, -1)
		res[i] = `"` + r + `"`
	}
	return []byte("{" + strings.Join(res, ",") + "}"), nil
}
1261006
func (o UUID) Value() (value driver.Value, err error) {
	if IsNil(o) {
		value, err = nil, nil
		return
	}
	value, err = o.MarshalText()
	return
}
576607
func (setting Setting) Value() (driver.Value, error) {
	result, err := json.Marshal(setting)
	return string(result), err
}
1106842
func (p *Point) Value() (driver.Value, error) {
	if p.Point == nil {
		return nil, nil
	}
	return value(p.Point)
}
568944
func (d Date) Value() (driver.Value, error) {
	year, month, day := d.Date()
	return time.Date(year, month, day, 0, 0, 0, 0, time.UTC), nil
}
282571
func (s String) Value() (driver.Value, error) {
	if !s.Valid {
		return nil, nil
	}
	return s.Chars, nil
}
484489
func (n NullTime) Value() (driver.Value, error) {
	if !n.Valid {
		return nil, nil
	}
	return n.Time, nil
}
715944
func (src *Float8) Value() (driver.Value, error) {
	switch src.Status {
	case Present:
		return src.Float, nil
	case Null:
		return nil, nil
	default:
		return nil, errUndefined
	}
}