fix: correctly escape backslash in queries (#10522)

# Which Problems Are Solved

While investigating a support ticket, it was discovered that some
queries using equals or not equals without case matching were not
correctly escaping the value to compare. If a value contained a
backslash (`\`) the row would not match.

# How the Problems Are Solved

- Fixed the escaping for backslash for `like` operations.
- Changed equals and not equals comparison without case matching to `=`
instead of `like`.

# Additional Changes

None

# Additional Context

- related to a support request
- requires backport to v.3 and v4.x
This commit is contained in:
Livio Spring
2025-08-21 07:25:23 +02:00
committed by GitHub
parent a28950661c
commit 6c8d027e72
3 changed files with 26 additions and 14 deletions

View File

@@ -206,6 +206,7 @@ func (c Config) Type() dialect.DatabaseType {
}
func EscapeLikeWildcards(value string) string {
value = strings.ReplaceAll(value, "\\", "\\\\")
value = strings.ReplaceAll(value, "%", "\\%")
value = strings.ReplaceAll(value, "_", "\\_")
return value