Skip to content

Commit a22a9f4

Browse files
committed
add ctrl+z as escape character
1 parent 2f1daeb commit a22a9f4

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

sql/parser.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,12 @@ func RemoveSpaceAndDelimiter(query string, d rune) string {
133133
})
134134
}
135135

136+
// EscapeSpecialCharactersInComment escapes special characters in a comment string.
136137
func EscapeSpecialCharactersInComment(comment string) string {
137138
commentString := comment
138139
commentString = strings.ReplaceAll(commentString, "'", "''")
139140
commentString = strings.ReplaceAll(commentString, "\\", "\\\\")
141+
commentString = strings.ReplaceAll(commentString, "\\Z", "\x1A") // MYSQL handles \\ first, then \Z
140142
commentString = strings.ReplaceAll(commentString, "\"", "\\\"")
141143
commentString = strings.ReplaceAll(commentString, "\n", "\\n")
142144
commentString = strings.ReplaceAll(commentString, "\r", "\\r")

0 commit comments

Comments
 (0)