pub struct PgArray<T>(pub Vec<T>);Expand description
Wrapper for passing a Vec<T> as a single PostgreSQL array parameter.
Without this wrapper, Vec<T> implements ToSQL by joining elements
with commas ($1, $2, $3), which is correct for IN (...) clauses
but wrong for array operators like @>, <@, and && which expect
a single array parameter.
§Example
let tags = SQL::<PostgresValue>::raw("tags");
// Correct: passes as a single array parameter
let condition = array_contains(tags, PgArray(vec!["rust", "python"]));Tuple Fields§
§0: Vec<T>Trait Implementations§
Source§impl<'a, T> ToSQL<'a, PostgresValue<'a>> for PgArray<T>
impl<'a, T> ToSQL<'a, PostgresValue<'a>> for PgArray<T>
fn to_sql(&self) -> SQL<'a, PostgresValue<'a>>
Source§fn into_sql(self) -> SQL<'a, V>where
Self: Sized,
fn into_sql(self) -> SQL<'a, V>where
Self: Sized,
Consume self and return SQL without cloning.
Default delegates to
to_sql() (which clones). Types that own their SQL
(like SQL and SQLExpr) override this to avoid the clone.fn alias(&self, alias: &'static str) -> SQL<'a, V>
Auto Trait Implementations§
impl<T> Freeze for PgArray<T>
impl<T> RefUnwindSafe for PgArray<T>where
T: RefUnwindSafe,
impl<T> Send for PgArray<T>where
T: Send,
impl<T> Sync for PgArray<T>where
T: Sync,
impl<T> Unpin for PgArray<T>where
T: Unpin,
impl<T> UnwindSafe for PgArray<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more