Expand description
Type-safe SQL escaping for PostgreSQL.
This module provides wrapper types that guarantee SQL values have been properly escaped at construction time. By using these types instead of raw strings, the type system ensures that escaping cannot be forgotten.
§Example
use spawn_db::{sql_query, escape::{EscapedIdentifier, EscapedLiteral}};
let schema = EscapedIdentifier::new("my_schema");
let value = EscapedLiteral::new("user's input");
let query = sql_query!(
"SELECT * FROM {}.users WHERE name = {}",
schema,
value
);Structs§
- Escaped
Identifier - A PostgreSQL identifier (schema, table, column name) that has been safely escaped.
- Escaped
Literal - A PostgreSQL string literal that has been safely escaped.
- Escaped
Query - A complete SQL query that has been constructed using only safe components.
- Insecure
RawSql - Raw SQL that has not been escaped.
Traits§
- SqlSafe
- A trait for types that are safe to interpolate into SQL queries.