MCPcopy
hub / github.com/micro/go-micro / scanRows

Function scanRows

model/sqlite/sqlite.go:352–369  ·  view source on GitHub ↗
(schema *model.Schema, rows *sql.Rows)

Source from the content-addressed store, hash-verified

350}
351
352func scanRows(schema *model.Schema, rows *sql.Rows) ([]map[string]any, error) {
353 var results []map[string]any
354 for rows.Next() {
355 ptrs := make([]any, len(schema.Fields))
356 for i, f := range schema.Fields {
357 ptrs[i] = newScanPtr(f.Type)
358 }
359 if err := rows.Scan(ptrs...); err != nil {
360 return nil, fmt.Errorf("model/sqlite: scan row: %w", err)
361 }
362 row := make(map[string]any, len(schema.Fields))
363 for i, f := range schema.Fields {
364 row[f.Column] = derefScanPtr(ptrs[i], f.Type)
365 }
366 results = append(results, row)
367 }
368 return results, rows.Err()
369}
370
371func newScanPtr(t reflect.Type) any {
372 switch t.Kind() {

Callers 1

ListMethod · 0.70

Calls 5

newScanPtrFunction · 0.70
derefScanPtrFunction · 0.70
NextMethod · 0.65
ScanMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…