@todo consider adding support for custom single character wildcard wrapLikeParams wraps each provided param value string with `%` if the param doesn't contain an explicit wildcard (`%`) character already.
(params dbx.Params)
| 482 | // wrapLikeParams wraps each provided param value string with `%` |
| 483 | // if the param doesn't contain an explicit wildcard (`%`) character already. |
| 484 | func wrapLikeParams(params dbx.Params) dbx.Params { |
| 485 | result := dbx.Params{} |
| 486 | |
| 487 | for k, v := range params { |
| 488 | vStr := cast.ToString(v) |
| 489 | if !containsUnescapedChar(vStr, '%') { |
| 490 | // note: this is done to minimize the breaking changes and to preserve the original autoescape behavior |
| 491 | vStr = escapeUnescapedChars(vStr, '\\', '%', '_') |
| 492 | vStr = "%" + vStr + "%" |
| 493 | } |
| 494 | result[k] = vStr |
| 495 | } |
| 496 | |
| 497 | return result |
| 498 | } |
| 499 | |
| 500 | func escapeUnescapedChars(str string, escapeChars ...rune) string { |
| 501 | rs := []rune(str) |
no test coverage detected
searching dependent graphs…