MCPcopy
hub / github.com/go-sql-driver/mysql / escapeStringQuotes

Function escapeStringQuotes

utils.go:718–737  ·  view source on GitHub ↗

escapeStringQuotes is similar to escapeBytesQuotes but for string.

(buf []byte, v string)

Source from the content-addressed store, hash-verified

716
717// escapeStringQuotes is similar to escapeBytesQuotes but for string.
718func escapeStringQuotes(buf []byte, v string) []byte {
719 pos := len(buf)
720 buf = reserveBuffer(buf, len(v)*2+2)
721 buf[pos] = '\''
722 pos++
723 for i := range len(v) {
724 c := v[i]
725 if c == '\'' {
726 buf[pos+1] = '\''
727 buf[pos] = '\''
728 pos += 2
729 } else {
730 buf[pos] = c
731 pos++
732 }
733 }
734 buf[pos] = '\''
735 pos++
736 return buf[:pos]
737}
738
739/******************************************************************************
740* Sync utils *

Callers 2

TestEscapeQuotesFunction · 0.85
interpolateParamsMethod · 0.85

Calls 1

reserveBufferFunction · 0.85

Tested by 1

TestEscapeQuotesFunction · 0.68