Skip to main content

PgRow

Struct PgRow 

Source
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§

Source§

impl PgRow

Source

pub fn into_inner(self) -> Row

Move the wrapped tokio_postgres::Row out of this wrapper.

Methods from Deref<Target = Row>§

Source

pub fn columns(&self) -> &[Column]

Returns information about the columns of data in the row.

Source

pub fn is_empty(&self) -> bool

Determines if the row contains no values.

Source

pub fn len(&self) -> usize

Returns the number of values in the row.

Source

pub fn get<'a, I, T>(&'a self, idx: I) -> T
where I: RowIndex + Display, T: FromSql<'a>,

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.

Source

pub fn try_get<'a, I, T>(&'a self, idx: I) -> Result<T, Error>
where I: RowIndex + Display, T: FromSql<'a>,

Like Row::get, but returns a Result rather than panicking.

Source

pub fn raw_size_bytes(&self) -> usize

Returns the raw size of the row in bytes.

Trait Implementations§

Source§

impl Deref for PgRow

Source§

type Target = Row

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl From<Row> for PgRow

Source§

fn from(row: Row) -> Self

Converts to this type from the input type.
Source§

impl RowRef for PgRow

Source§

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:

  • UUID columns — emitted as String for Prisma String @db.Uuid fields. We decode via uuid::Uuid::from_sql and stringify.
  • User-defined ENUM columns — also emitted as String via FromColumn’s get_string call (see codegen for enum variants). We decode via AnyText since &str: FromSql does 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>

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.

Source§

fn get_i32(&self, c: &str) -> Result<i32, RowError>

Get an integer column value.
Source§

fn get_i32_opt(&self, c: &str) -> Result<Option<i32>, RowError>

Get an optional integer column value.
Source§

fn get_i64(&self, c: &str) -> Result<i64, RowError>

Get a 64-bit integer column value.
Source§

fn get_i64_opt(&self, c: &str) -> Result<Option<i64>, RowError>

Get an optional 64-bit integer column value.
Source§

fn get_f64(&self, c: &str) -> Result<f64, RowError>

Get a float column value.
Source§

fn get_f64_opt(&self, c: &str) -> Result<Option<f64>, RowError>

Get an optional float column value.
Source§

fn get_bool(&self, c: &str) -> Result<bool, RowError>

Get a boolean column value.
Source§

fn get_bool_opt(&self, c: &str) -> Result<Option<bool>, RowError>

Get an optional boolean column value.
Source§

fn get_str(&self, c: &str) -> Result<&str, RowError>

Get a string column value as a borrowed reference (zero-copy). Read more
Source§

fn get_str_opt(&self, c: &str) -> Result<Option<&str>, RowError>

Get an optional string column value as a borrowed reference.
Source§

fn get_string_opt(&self, c: &str) -> Result<Option<String>, RowError>

Get an optional string as owned.
Source§

fn get_bytes(&self, c: &str) -> Result<&[u8], RowError>

Get a bytes column value as a borrowed reference (zero-copy).
Source§

fn get_bytes_opt(&self, c: &str) -> Result<Option<&[u8]>, RowError>

Get optional bytes as borrowed reference.
Source§

fn get_datetime_utc(&self, c: &str) -> Result<DateTime<Utc>, RowError>

Source§

fn get_datetime_utc_opt( &self, c: &str, ) -> Result<Option<DateTime<Utc>>, RowError>

Source§

fn get_naive_datetime(&self, c: &str) -> Result<NaiveDateTime, RowError>

Source§

fn get_naive_datetime_opt( &self, c: &str, ) -> Result<Option<NaiveDateTime>, RowError>

Source§

fn get_naive_date(&self, c: &str) -> Result<NaiveDate, RowError>

Source§

fn get_naive_date_opt(&self, c: &str) -> Result<Option<NaiveDate>, RowError>

Source§

fn get_naive_time(&self, c: &str) -> Result<NaiveTime, RowError>

Source§

fn get_naive_time_opt(&self, c: &str) -> Result<Option<NaiveTime>, RowError>

Source§

fn get_uuid(&self, c: &str) -> Result<Uuid, RowError>

Source§

fn get_uuid_opt(&self, c: &str) -> Result<Option<Uuid>, RowError>

Source§

fn get_json(&self, c: &str) -> Result<Value, RowError>

Source§

fn get_json_opt(&self, c: &str) -> Result<Option<Value>, RowError>

Source§

fn get_decimal(&self, c: &str) -> Result<Decimal, RowError>

Source§

fn get_decimal_opt(&self, c: &str) -> Result<Option<Decimal>, RowError>

Source§

fn get_cow_str(&self, column: &str) -> Result<Cow<'_, str>, RowError>

Get column value as a Cow, borrowing when possible.
Source§

fn get_vector(&self, column: &str) -> Result<Vec<f32>, RowError>

Get a pgvector column as a dense Vec<f32>. Read more

Auto Trait Implementations§

§

impl !Freeze for PgRow

§

impl !RefUnwindSafe for PgRow

§

impl Send for PgRow

§

impl Sync for PgRow

§

impl Unpin for PgRow

§

impl UnsafeUnpin for PgRow

§

impl !UnwindSafe for PgRow

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more