Skip to content

Commit 919e7ca

Browse files
committed
Expand interpolateParams tests to handle backslash-escaped string literals.
1 parent 50f682d commit 919e7ca

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

connection_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ func TestInterpolateParamsWithComments(t *testing.T) {
212212
{"SELECT '?', ?", []driver.Value{int64(42)}, "SELECT '?', 42", false},
213213
// ? in backtick identifier should not be replaced
214214
{"SELECT `?`, ?", []driver.Value{int64(42)}, "SELECT `?`, 42", false},
215+
// ? in backslash-escaped string literal should not be replaced
216+
{"SELECT 'C:\\path\\?x.txt', ?", []driver.Value{int64(42)}, "SELECT 'C:\\path\\?x.txt', 42", false},
217+
// ? in backslash-escaped string literal should not be replaced
218+
{"SELECT '\\'?', col FROM tbl WHERE id = ? AND desc = 'foo\\'bar?'", []driver.Value{int64(42)}, "SELECT '\\'?', col FROM tbl WHERE id = 42 AND desc = 'foo\\'bar?'", false},
215219
// Multiple comments and real placeholders
216220
{"SELECT ? -- comment ?\n, ? /* ? */ , ? # ?\n, ?", []driver.Value{int64(1), int64(2), int64(3)}, "SELECT 1 -- comment ?\n, 2 /* ? */ , 3 # ?\n, ?", true},
217221
}

0 commit comments

Comments
 (0)