Skip to content

Commit 2382b8b

Browse files
authored
Remove unneeded backslash ESCAPE from LIKE translations (#3103)
Fixes #3085
1 parent c0c962c commit 2382b8b

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/EFCore.PG/Query/Internal/NpgsqlSqlTranslatingExpressionVisitor.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,7 @@ when patternParameter.Name.StartsWith(QueryCompilationContext.QueryParameterPref
456456

457457
translation = _sqlExpressionFactory.Like(
458458
translatedInstance,
459-
new SqlParameterExpression(escapedPatternParameter.Name!, escapedPatternParameter.Type, stringTypeMapping),
460-
_sqlExpressionFactory.Constant(LikeEscapeChar.ToString()));
459+
new SqlParameterExpression(escapedPatternParameter.Name!, escapedPatternParameter.Type, stringTypeMapping));
461460

462461
return true;
463462
}

test/EFCore.PG.FunctionalTests/Query/CitextQueryTest.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void StartsWith_param_pattern()
4848
4949
SELECT s."Id", s."CaseInsensitiveText"
5050
FROM "SomeEntities" AS s
51-
WHERE s."CaseInsensitiveText" LIKE @__param_0_startswith ESCAPE '\'
51+
WHERE s."CaseInsensitiveText" LIKE @__param_0_startswith
5252
LIMIT 2
5353
""");
5454
}
@@ -102,7 +102,7 @@ public void EndsWith_param_pattern()
102102
103103
SELECT s."Id", s."CaseInsensitiveText"
104104
FROM "SomeEntities" AS s
105-
WHERE s."CaseInsensitiveText" LIKE @__param_0_endswith ESCAPE '\'
105+
WHERE s."CaseInsensitiveText" LIKE @__param_0_endswith
106106
LIMIT 2
107107
""");
108108
}
@@ -156,7 +156,7 @@ public void Contains_param_pattern()
156156
157157
SELECT s."Id", s."CaseInsensitiveText"
158158
FROM "SomeEntities" AS s
159-
WHERE s."CaseInsensitiveText" LIKE @__param_0_contains ESCAPE '\'
159+
WHERE s."CaseInsensitiveText" LIKE @__param_0_contains
160160
LIMIT 2
161161
""");
162162
}

0 commit comments

Comments
 (0)