MCPcopy Create free account
hub / github.com/CrunchyData/postgres-operator / QuoteLiteral

Function QuoteLiteral

internal/postgres/sql.go:16–22  ·  view source on GitHub ↗

QuoteLiteral escapes v so it can be safely used as a literal (or constant) in an SQL statement.

(v string)

Source from the content-addressed store, hash-verified

14// QuoteLiteral escapes v so it can be safely used as a literal (or constant)
15// in an SQL statement.
16func QuoteLiteral(v string) string {
17 // Use the "escape" syntax to ensure that backslashes behave consistently regardless
18 // of the "standard_conforming_strings" parameter. Include a space before so
19 // the "E" cannot change the meaning of an adjacent SQL keyword or identifier.
20 // - https://www.postgresql.org/docs/current/sql-syntax-lexical.html
21 return ` E'` + escapeLiteral(v) + `'`
22}

Callers 2

sqlAuthenticationQueryFunction · 0.92
TestQuoteLiteralFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestQuoteLiteralFunction · 0.68