derive feature on, better-duck-core’s data derives are re-exported from
better_duck_diesel with Diesel FromSql/ToSql emission enabled. The same Rust type that maps to
a DuckDB ENUM or STRUCT in core then also binds and loads through a DuckDbConnection at its
sql_types::DuckEnum / sql_types::DuckStruct column type.
What the feature does
The core derives (DuckEnum, DuckStruct, FromRow, ToRow) always exist in core. Turning on
better-duck-diesel/derive makes DuckEnum and DuckStruct additionally emit Diesel ToSql /
FromSql impls against better_duck_diesel::sql_types::DuckEnum / DuckStruct. Mechanically this flips
on core’s derive-diesel feature, whose generated code resolves ::better_duck_diesel in your crate —
so core itself never gains a Diesel dependency. See
core feature flags.
The ORM path for these DuckDB-specific types is
sql_query + QueryableByName (not the plain
Queryable builder), because the Duck* SQL types have no Queryable blanket impl — see
Type mapping.Mapping an enum to ENUM
Mapping a struct to STRUCT
#[derive(DuckStruct)] works the same way at sql_types::DuckStruct — bind with
.bind::<DuckStructSql, _>(value) and read via a QueryableByName field typed
#[diesel(sql_type = DuckStructSql)].
Renaming
Field/variant renaming honors#[duck(rename = "…")] / #[duck(rename_all = "…")] (and the
#[duck_enum(...)] forms for enums), identical to the core derives. The full casing list and resolution
order are on the data derives page.
Re-exports
Available frombetter_duck_diesel under the derive feature: FromRow, ToRow, DuckEnum,
DuckStruct.
See also
Data derives (core)
Authoring
DuckEnum / DuckStruct and renaming rules.Type mapping
The
DuckEnum / DuckStruct SQL types.Schema
Declaring the columns these types back.
Feature flags
How
derive relates to core’s derive-diesel.