MCPcopy Index your code
hub / github.com/lib/pq / scanBytes

Method scanBytes

array.go:94–119  ·  view source on GitHub ↗
(src []byte)

Source from the content-addressed store, hash-verified

92}
93
94func (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.
122func (a BoolArray) Value() (driver.Value, error) {

Callers 1

ScanMethod · 0.95

Calls 1

scanLinearArrayFunction · 0.85

Tested by

no test coverage detected