MCPcopy
hub / github.com/jackc/pgx / Scan

Method Scan

pgtype/json.go:199–223  ·  view source on GitHub ↗
(src []byte, dst any)

Source from the content-addressed store, hash-verified

197}
198
199func (s *scanPlanJSONToJSONUnmarshal) Scan(src []byte, dst any) error {
200 if src == nil {
201 dstValue := reflect.ValueOf(dst)
202 if dstValue.Kind() == reflect.Pointer {
203 el := dstValue.Elem()
204 switch el.Kind() {
205 case reflect.Pointer, reflect.Slice, reflect.Map, reflect.Interface:
206 el.Set(reflect.Zero(el.Type()))
207 return nil
208 }
209 }
210
211 return fmt.Errorf("cannot scan NULL into %T", dst)
212 }
213
214 v := reflect.ValueOf(dst)
215 if v.Kind() != reflect.Pointer || v.IsNil() {
216 return fmt.Errorf("cannot scan into non-pointer or nil destinations %T", dst)
217 }
218
219 elem := v.Elem()
220 elem.Set(reflect.Zero(elem.Type()))
221
222 return s.unmarshal(src, dst)
223}
224
225func (c *JSONCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error) {
226 if src == nil {

Callers

nothing calls this directly

Calls 1

SetMethod · 0.80

Tested by

no test coverage detected