bindStruct binds a named parameter query with fields from a struct argument. The rules for binding field names to parameter names follow the same conventions as for StructScan, including obeying the `db` struct tags.
(bindType int, query string, arg interface{}, m *reflectx.Mapper)
| 211 | // The rules for binding field names to parameter names follow the same |
| 212 | // conventions as for StructScan, including obeying the `db` struct tags. |
| 213 | func bindStruct(bindType int, query string, arg interface{}, m *reflectx.Mapper) (string, []interface{}, error) { |
| 214 | bound, names, err := compileNamedQuery([]byte(query), bindType) |
| 215 | if err != nil { |
| 216 | return "", []interface{}{}, err |
| 217 | } |
| 218 | |
| 219 | arglist, err := bindAnyArgs(names, arg, m) |
| 220 | if err != nil { |
| 221 | return "", []interface{}{}, err |
| 222 | } |
| 223 | |
| 224 | return bound, arglist, nil |
| 225 | } |
| 226 | |
| 227 | var valuesReg = regexp.MustCompile(`\)\s*(?i)VALUES\s*\(`) |
| 228 |