Skip to main content

sql_forge_transparent

Attribute Macro sql_forge_transparent 

Source
#[sql_forge_transparent]
Expand description

Marks a single-value tuple struct as a transparent wrapper for use with sql_forge! parameters.

Expands to #[derive(sqlx::Type)] + #[sqlx(transparent)] (needed for all database backends so the type implements sqlx::Encode + sqlx::Type) and additionally implements SqlForgeValidatorValue<InnerType>, which is required for PostgreSQL to pass compile-time parameter validation in query_as!. MySQL and SQLite do not need to use the trait.

#[derive(Debug, PartialEq, Eq)]
#[sql_forge_transparent]
struct UserId(pub i64);