| 92 | } |
| 93 | |
| 94 | func (a *BoolArray) scanBytes(src []byte) error { |
| 95 | elems, err := scanLinearArray(src, []byte{','}, "BoolArray") |
| 96 | if err != nil { |
| 97 | return err |
| 98 | } |
| 99 | if *a != nil && len(elems) == 0 { |
| 100 | *a = (*a)[:0] |
| 101 | } else { |
| 102 | b := make(BoolArray, len(elems)) |
| 103 | for i, v := range elems { |
| 104 | if len(v) != 1 { |
| 105 | return fmt.Errorf("pq: could not parse boolean array index %d: invalid boolean %q", i, v) |
| 106 | } |
| 107 | switch v[0] { |
| 108 | case 't': |
| 109 | b[i] = true |
| 110 | case 'f': |
| 111 | b[i] = false |
| 112 | default: |
| 113 | return fmt.Errorf("pq: could not parse boolean array index %d: invalid boolean %q", i, v) |
| 114 | } |
| 115 | } |
| 116 | *a = b |
| 117 | } |
| 118 | return nil |
| 119 | } |
| 120 | |
| 121 | // Value implements the driver.Valuer interface. |
| 122 | func (a BoolArray) Value() (driver.Value, error) { |