Safely escapes a string literal for use inside single-quoted SQL statements, clauses, or ExtraFilter predicates.
Replaces each single quote with doubled single quotes ('') per ANSI SQL standard — the escaping
mechanism supported by both SQL Server and PostgreSQL — and removes null bytes (\0), which cannot
appear in any legitimate value and invite parser-level surprises when left in a predicate.
This escapes string literals and nothing else. It does not escape LIKE wildcards
(%, _, [) or identifier names, and null/undefined map to ''.
Parameters
value: string|null|undefined
The raw string value to escape. If null or undefined, returns empty string.
Returns string
Safely escaped string value (without surrounding quotes).
Safely escapes a string literal for use inside single-quoted SQL statements, clauses, or
ExtraFilterpredicates.Replaces each single quote with doubled single quotes (
'') per ANSI SQL standard — the escaping mechanism supported by both SQL Server and PostgreSQL — and removes null bytes (\0), which cannot appear in any legitimate value and invite parser-level surprises when left in a predicate.This escapes string literals and nothing else. It does not escape
LIKEwildcards (%,_,[) or identifier names, andnull/undefinedmap to''.