MCPcopy Create free account
hub / github.com/lib/pq / Value

Method Value

array.go:475–502  ·  view source on GitHub ↗

Value implements the driver.Valuer interface.

()

Source from the content-addressed store, hash-verified

473
474// Value implements the driver.Valuer interface.
475func (a GenericArray) Value() (driver.Value, error) {
476 if a.A == nil {
477 return nil, nil
478 }
479
480 rv := reflect.ValueOf(a.A)
481
482 switch rv.Kind() {
483 case reflect.Slice:
484 if rv.IsNil() {
485 return nil, nil
486 }
487 case reflect.Array:
488 default:
489 return nil, fmt.Errorf("pq: unable to convert %T to array", a.A)
490 }
491
492 if n := rv.Len(); n > 0 {
493 // There will be at least two curly brackets, N bytes of values,
494 // and N-1 bytes of delimiters.
495 b := make([]byte, 0, 1+2*n)
496
497 b, _, err := appendArray(b, rv, n)
498 return string(b), err
499 }
500
501 return "{}", nil
502}
503
504// Int64Array represents a one-dimensional array of the PostgreSQL integer types.
505type Int64Array []int64

Callers

nothing calls this directly

Calls 1

appendArrayFunction · 0.85

Tested by

no test coverage detected