Skip to main content

escape_csharp_verbatim_string

Function escape_csharp_verbatim_string 

Source
pub fn escape_csharp_verbatim_string(sql: &str) -> String
Expand description

Escape SQL text for splicing into a C# verbatim @"..." string literal.

The C# backends previously used a regular "..." string with no escaping at all, which breaks on both an embedded quote and a backslash (LIKE 'a\_b%' fails to compile outright, since \_ is not a recognized regular-string escape). Verbatim strings sidestep backslash entirely – it is literal there, exactly matching what SQL text needs – and permit raw newlines, so the only escape required is doubling an embedded " to "". Used by all six C# backends (csharp-npgsql, csharp-sqlclient, csharp-mysqlconnector, csharp-microsoft-sqlite, csharp-oracle, csharp-snowflake).