pub struct PgRow(/* private fields */);Expand description
Newtype wrapper around tokio_postgres::Row that implements
prax_query::row::RowRef.
The inner row is private; use PgRow::into_inner when ownership is
needed (e.g., forwarding to a tokio-postgres API that consumes Row).
For read-only access, the Deref<Target = Row> impl lets you call
any Row method directly.
Implementations§
Methods from Deref<Target = Row>§
Sourcepub fn get<'a, I, T>(&'a self, idx: I) -> T
pub fn get<'a, I, T>(&'a self, idx: I) -> T
Deserializes a value from the row.
The value can be specified either by its numeric index in the row, or by its column name.
§Panics
Panics if the index is out of bounds or if the value cannot be converted to the specified type.
Sourcepub fn try_get<'a, I, T>(&'a self, idx: I) -> Result<T, Error>
pub fn try_get<'a, I, T>(&'a self, idx: I) -> Result<T, Error>
Like Row::get, but returns a Result rather than panicking.
Sourcepub fn raw_size_bytes(&self) -> usize
pub fn raw_size_bytes(&self) -> usize
Returns the raw size of the row in bytes.
Trait Implementations§
Source§impl RowRef for PgRow
impl RowRef for PgRow
Source§fn get_string(&self, c: &str) -> Result<String, RowError>
fn get_string(&self, c: &str) -> Result<String, RowError>
Override the trait default (which is get_str + to_string) so
we can decode columns whose Postgres-side type is not TEXT but
whose Rust-side codegen has emitted pub field: String:
UUIDcolumns — emitted asStringfor PrismaString @db.Uuidfields. We decode viauuid::Uuid::from_sqland stringify.- User-defined
ENUMcolumns — also emitted asStringviaFromColumn’sget_stringcall (see codegen forenumvariants). We decode viaAnyTextsince&str: FromSqldoes not accept enum types.
Without this override, the row decode fails with "error deserializing column N" and the whole query bubbles up a
[P6003] type conversion error.
A matching override on get_string_opt covers nullable variants.
Source§fn is_null(&self, c: &str) -> Result<bool, RowError>
fn is_null(&self, c: &str) -> Result<bool, RowError>
Override the trait default (which falls back to get_str_opt, and
therefore fails for non-TEXT column types like INTEGER, UUID, etc.)
with a type-agnostic null probe.
NullProbe: FromSql accepts every Postgres wire type and discards
the payload entirely, so Option<NullProbe> deserialises to None
on NULL and Some(NullProbe) on any non-null value — regardless of
the column’s OID — without attempting any byte interpretation. This
is exactly what the blanket impl<T: FromColumn> FromColumn for Option<T> needs to short-circuit nullable columns of any type.