| 19 | } |
| 20 | |
| 21 | func (tu *templateWithUtils) PlaceholderValue(in interface{}) (exql.Fragment, []interface{}) { |
| 22 | switch t := in.(type) { |
| 23 | case *adapter.RawExpr: |
| 24 | return &exql.Raw{Value: t.Raw()}, t.Arguments() |
| 25 | case *adapter.FuncExpr: |
| 26 | fnName := t.Name() |
| 27 | fnArgs := []interface{}{} |
| 28 | args, _ := toInterfaceArguments(t.Arguments()) |
| 29 | fragments := []string{} |
| 30 | for i := range args { |
| 31 | frag, args := tu.PlaceholderValue(args[i]) |
| 32 | fragment, err := frag.Compile(tu.Template) |
| 33 | if err == nil { |
| 34 | fragments = append(fragments, fragment) |
| 35 | fnArgs = append(fnArgs, args...) |
| 36 | } |
| 37 | } |
| 38 | return &exql.Raw{Value: fnName + `(` + strings.Join(fragments, `, `) + `)`}, fnArgs |
| 39 | default: |
| 40 | return sqlPlaceholder, []interface{}{in} |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | // toWhereWithArguments converts the given parameters into a exql.Where value. |
| 45 | func (tu *templateWithUtils) toWhereWithArguments(term interface{}) (where exql.Where, args []interface{}) { |