MCPcopy
hub / github.com/jmoiron/sqlx / MapScan

Function MapScan

sqlx.go:837–859  ·  view source on GitHub ↗

MapScan scans a single Row into the dest map[string]interface{}. Use this to get results for SQL that might not be under your control (for instance, if you're building an interface for an SQL server that executes SQL from input). Please do not use this as a primary interface! This will modify the m

(r ColScanner, dest map[string]interface{})

Source from the content-addressed store, hash-verified

835// care. Columns which occur more than once in the result will overwrite
836// each other!
837func MapScan(r ColScanner, dest map[string]interface{}) error {
838 // ignore r.started, since we needn't use reflect for anything.
839 columns, err := r.Columns()
840 if err != nil {
841 return err
842 }
843
844 values := make([]interface{}, len(columns))
845 for i := range values {
846 values[i] = new(interface{})
847 }
848
849 err = r.Scan(values...)
850 if err != nil {
851 return err
852 }
853
854 for i, column := range columns {
855 dest[column] = *(values[i].(*interface{}))
856 }
857
858 return r.Err()
859}
860
861type rowsi interface {
862 Close() error

Callers 2

MapScanMethod · 0.85
MapScanMethod · 0.85

Calls 3

ColumnsMethod · 0.65
ScanMethod · 0.65
ErrMethod · 0.65

Tested by

no test coverage detected