Expand description
Bridge between tokio_postgres::Row and prax_query::row::RowRef.
RowRef is defined in prax-query and Row is defined in tokio-postgres;
both are foreign to this crate, so Rust’s orphan rules forbid a direct
impl RowRef for Row. We wrap the row in a #[repr(transparent)] newtype
(PgRow) and implement the trait on the wrapper.
§Dual API surface
PgRow derefs to the wrapped Row, so callers can use either API:
- The generic
RowRefinterface (pg_row.get_i32("id")) — portable across drivers and what generatedFromRowimpls use. - The native
tokio_postgres::Rowinterface (pg_row.try_get::<_, i32>("id")) — full access to the driver’s type system for columnsRowRefdoes not model (arrays, range types, etc.).
§rust_decimal limitation
tokio-postgres 0.7 has no with-rust_decimal-* feature gate and
rust_decimal::Decimal therefore has no FromSql impl through the driver.
PgRow::get_decimal and PgRow::get_decimal_opt fall back to the trait’s
default implementations, which return a RowError::TypeConversion marked
“decimal not supported by this row type”. Until we add a bridging
FromSql/ToSql impl (or switch to a driver that exposes the feature),
callers that need decimal values should cast the column to text
(amount::text) and parse in application code.
Structs§
- PgRow
- Newtype wrapper around
tokio_postgres::Rowthat implementsprax_query::row::RowRef.