Value implements the driver.Valuer interface.
()
| 473 | |
| 474 | // Value implements the driver.Valuer interface. |
| 475 | func (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. |
| 505 | type Int64Array []int64 |
nothing calls this directly
no test coverage detected