Expand description
Procedural macros for the oracledb driver.
This crate hosts the #[derive(FromRow)] macro. It is an implementation
detail of the oracledb crate: end users never depend on it directly. The
oracledb crate re-exports the derive (gated behind its default-on derive
feature) alongside the FromRow trait the generated code implements, so the
single import
use oracledb::FromRow;brings both the trait and the derive into scope.
§What the derive generates
For a struct
#[derive(FromRow)]
struct Emp { id: i64, name: String, hired: Option<chrono::NaiveDate> }the macro emits an impl oracledb::FromRow for Emp, whose from_row pulls
each field out of the row by column name through the existing typed
accessor (TypedRow::get_by_name), which itself goes through the real
FromSql conversion. There is no stringly-typed shortcut: an i64 field is
genuinely converted from the Oracle NUMBER, an Option<T> field accepts a
SQL NULL, and a chrono::NaiveDate field is decoded from a DATE.
§Supported shapes and attributes
- Named-field structs — each field maps to a column named after the field.
- Tuple structs — each field maps to a column by position (index 0, 1, …).
#[oracledb(rename_all = "UPPERCASE" | "lowercase" | "snake_case" | "SCREAMING_SNAKE_CASE" | "camelCase" | "PascalCase")]on the struct renames every field’s column (column resolution is case-insensitive, soUPPERCASE/lowercaseare cosmetic, but the others change word casing).#[oracledb(column = "…")]on a field overrides that one column name.#[oracledb(rename = "…")]is an accepted alias forcolumn = "…".
Enums, unions, and unit/zero-field structs produce a clear compile_error!.
Derive Macros§
- FromRow
- Derive an
oracledb::FromRowimplementation that maps a query row into the annotated struct, with compile-time-checked field types.