Skip to main content

quote_identifier

Function quote_identifier 

Source
pub fn quote_identifier(name: &str) -> Option<String>
Expand description

Quote a table or type name for use in SQL.

Identifiers cannot be bound as parameters, so this is the one place names reach SQL as text. Only lowercase ASCII letters, digits, and underscores are accepted, starting with a letter or underscore. That is stricter than Postgres, and it leaves nothing for an attacker to work with.

assert_eq!(axa_sqlx::quote_identifier("users").as_deref(), Some("\"users\""));
assert_eq!(axa_sqlx::quote_identifier("users; DROP TABLE x"), None);