MCPcopy Create free account
hub / github.com/bytebase/bytebase / escapeSQLString

Function escapeSQLString

backend/component/export/sql.go:120–134  ·  view source on GitHub ↗
(engine storepb.Engine, v []byte)

Source from the content-addressed store, hash-verified

118}
119
120func escapeSQLString(engine storepb.Engine, v []byte) []byte {
121 switch engine {
122 case storepb.Engine_POSTGRES, storepb.Engine_REDSHIFT:
123 escapedStr := pq.QuoteLiteral(string(v))
124 return []byte(escapedStr)
125 default:
126 result := []byte("'")
127 s := strconv.Quote(string(v))
128 s = s[1 : len(s)-1]
129 s = strings.ReplaceAll(s, `'`, `''`)
130 result = append(result, []byte(s)...)
131 result = append(result, '\'')
132 return result
133 }
134}
135
136func escapeSQLBytes(_ storepb.Engine, v []byte) []byte {
137 // Use hex encoding for all engines (SQL standard)

Callers 1

convertValueToBytesInSQLFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected