#[pg_enum]Expand description
Derive PostgreSQL enum <-> Rust enum mapping with FromSql and ToSql.
§Usage
ⓘ
#[bsql::pg_enum]
pub enum TicketStatus {
#[sql("new")]
New,
#[sql("in_progress")]
InProgress,
#[sql("resolved")]
Resolved,
#[sql("closed")]
Closed,
}Each variant must have a #[sql("label")] attribute mapping it to the
exact PostgreSQL enum label. The macro generates:
FromSql— deserializes from PostgreSQL text representationToSql— serializes to PostgreSQL text representationDisplay— formats as the SQL label- Derives:
Debug, Clone, Copy, PartialEq, Eq, Hash
If PostgreSQL sends a variant not present in the Rust enum, FromSql
returns an error describing the schema mismatch.