| 419 | } |
| 420 | |
| 421 | func 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 |