ch some
This commit is contained in:
11
internal/shared/query.go
Normal file
11
internal/shared/query.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package shared
|
||||
|
||||
import "strings"
|
||||
|
||||
// LikePattern escapes SQL LIKE metacharacters and wraps term for a %term% match.
|
||||
func LikePattern(term string) string {
|
||||
term = strings.ReplaceAll(term, `\`, `\\`)
|
||||
term = strings.ReplaceAll(term, `%`, `\%`)
|
||||
term = strings.ReplaceAll(term, `_`, `\_`)
|
||||
return "%" + term + "%"
|
||||
}
|
||||
Reference in New Issue
Block a user