pub fn sql_literal(v: &Value) -> StringExpand description
Render a JSON scalar as an ANSI-standard SQL literal: strings are
single-quoted with embedded quotes doubled (''), numbers and booleans pass
through in their canonical form, and anything else becomes NULL.
This is the house escaper for every dialect that follows the ANSI rule —
Postgres (with standard_conforming_strings, the default since 9.1), MySQL
under NO_BACKSLASH_ESCAPES, SQL Server, and SQLite. Not BigQuery:
GoogleSQL treats \' as an escaped quote, so a trailing backslash would
close the literal early. Public so connectors escape
through one audited implementation instead of hand-rolling a third
convention (#654 M14): the copies that existed before it was exported each
invented their own rules, so a fix to one reached none of the others.
A dialect whose string literals treat some other character as a
meta-character cannot use this function — doubling quotes alone does not
neutralise a trailing escape character. Such a dialect must keep its own
escaper, and that escaper’s doc comment must state which extra characters it
escapes and why (see faucet_common_clickhouse::sql_literal, where a
backslash is a literal meta-character).