Skip to main content

Module escape

Module escape 

Source
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§

EscapedIdentifier
A PostgreSQL identifier (schema, table, column name) that has been safely escaped.
EscapedLiteral
A PostgreSQL string literal that has been safely escaped.
EscapedQuery
A complete SQL query that has been constructed using only safe components.
InsecureRawSql
Raw SQL that has not been escaped.

Traits§

SqlSafe
A trait for types that are safe to interpolate into SQL queries.