expandQuery replaces the placeholders in the query with the actual values and returns the expanded query and the arguments to be used in the query.
(query string, args ...any)
| 3651 | // expandQuery replaces the placeholders in the query with the actual values and returns |
| 3652 | // the expanded query and the arguments to be used in the query. |
| 3653 | func expandQuery(query string, args ...any) (string, []any) { |
| 3654 | var expandedArgs []any |
| 3655 | var expandedQuery string |
| 3656 | |
| 3657 | if len(args) != strings.Count(query, "?") { |
| 3658 | args = flattenSlice(args) |
| 3659 | } |
| 3660 | expandedQuery, expandedArgs, _ = sqlx.In(query, args...) |
| 3661 | return sqlx.Rebind(sqlx.DOLLAR, expandedQuery), expandedArgs |
| 3662 | } |
| 3663 | |
| 3664 | // flatMap converts a slice of mixed values/slices into a flat slice. |
| 3665 | func flattenSlice(slice []any) []any { |
no test coverage detected
searching dependent graphs…