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

Function bindNamedMapper

named.go:421–436  ·  view source on GitHub ↗
(bindType int, query string, arg interface{}, m *reflectx.Mapper)

Source from the content-addressed store, hash-verified

419}
420
421func bindNamedMapper(bindType int, query string, arg interface{}, m *reflectx.Mapper) (string, []interface{}, error) {
422 t := reflect.TypeOf(arg)
423 k := t.Kind()
424 switch {
425 case k == reflect.Map && t.Key().Kind() == reflect.String:
426 m, ok := convertMapStringInterface(arg)
427 if !ok {
428 return "", nil, fmt.Errorf("sqlx.bindNamedMapper: unsupported map type: %T", arg)
429 }
430 return bindMap(bindType, query, m)
431 case k == reflect.Array || k == reflect.Slice:
432 return bindArray(bindType, query, arg, m)
433 default:
434 return bindStruct(bindType, query, arg, m)
435 }
436}
437
438// NamedQuery binds a named query and then runs Query on the result using the
439// provided Ext (sqlx.Tx, sqlx.Db). It works with both structs and with

Callers 9

BindNamedMethod · 0.85
BindNamedMethod · 0.85
NamedQueryContextFunction · 0.85
NamedExecContextFunction · 0.85
BindNamedFunction · 0.85
NamedFunction · 0.85
NamedQueryFunction · 0.85
NamedExecFunction · 0.85
TestBindNamedMapperFunction · 0.85

Calls 6

bindMapFunction · 0.85
bindArrayFunction · 0.85
bindStructFunction · 0.85
KindMethod · 0.80
ErrorfMethod · 0.80

Tested by 1

TestBindNamedMapperFunction · 0.68