Skip to main content

escape_sql_literal

Function escape_sql_literal 

Source
pub fn escape_sql_literal(value: &str) -> String
Expand description

Escapes value for safe interpolation inside a single-quoted SQL string literal, by doubling any embedded single quote (the standard SQL escaping - understood by Postgres, SQL Server, and SQLite alike). Every place in this crate that writes a user-supplied value (identifier, enum code, configured username, …) inside '...' must go through this first: an unescaped embedded quote breaks the generated SQL at best, or lets the value’s content escape the string literal and inject arbitrary SQL at worst.