pub fn quote_literal(s: &str, writer: &mut impl Write)
Expand description
quote_literal(string text)
quote_literal(value anyelement)
Return the given string suitably quoted to be used as a string literal in an SQL statement
string. Embedded single-quotes and backslashes are properly doubled.
Note that quote_literal
returns null on null input; if the argument might be null,
quote_nullable
is often more suitable.
ยงExample
Note that the quotes are part of the output string.
query T
select quote_literal(E'O\'Reilly')
----
'O''Reilly'
query T
select quote_literal(E'C:\\Windows\\')
----
E'C:\\Windows\\'
query T
select quote_literal(42.5)
----
'42.5'
query T
select quote_literal('hello'::bytea);
----
E'\\x68656c6c6f'
query T
select quote_literal('{"hello":"world","foo":233}'::jsonb);
----
'{"foo": 233, "hello": "world"}'