MCPcopy
hub / github.com/pocketbase/pocketbase / wrapLikeParams

Function wrapLikeParams

tools/search/filter.go:484–498  ·  view source on GitHub ↗

@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)

Source from the content-addressed store, hash-verified

482// wrapLikeParams wraps each provided param value string with `%`
483// if the param doesn't contain an explicit wildcard (`%`) character already.
484func 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
500func escapeUnescapedChars(str string, escapeChars ...rune) string {
501 rs := []rune(str)

Callers 1

buildResolversExprFunction · 0.85

Calls 2

containsUnescapedCharFunction · 0.85
escapeUnescapedCharsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…