pub struct PgHelpers;Expand description
PostgreSQL-specific query helpers.
Implementations§
Source§impl PgHelpers
impl PgHelpers
Sourcepub async fn query_returning(pool: &PgPool, sql: &str) -> SqlxResult<Vec<PgRow>>
pub async fn query_returning(pool: &PgPool, sql: &str) -> SqlxResult<Vec<PgRow>>
Execute a query with RETURNING clause.
Sourcepub async fn upsert(
_pool: &PgPool,
table: &str,
columns: &[&str],
conflict_columns: &[&str],
update_columns: &[&str],
) -> SqlxResult<String>
pub async fn upsert( _pool: &PgPool, table: &str, columns: &[&str], conflict_columns: &[&str], update_columns: &[&str], ) -> SqlxResult<String>
Build INSERT … ON CONFLICT SQL (does not execute; run it via your pool).
The pool parameter is currently unused; it is reserved for a future
executing variant. Identifiers are quoted via quote_identifier;
pass trusted identifiers only, not arbitrary user input.
Sourcepub fn array_literal<T: Display>(values: &[T]) -> String
pub fn array_literal<T: Display>(values: &[T]) -> String
Generate a PostgreSQL array literal.
Embedded single quotes in values are escaped (' -> ''). Prefer
bound parameters for untrusted values.
Sourcepub fn json_path(column: &str, path: &[&str]) -> String
pub fn json_path(column: &str, path: &[&str]) -> String
Generate a PostgreSQL JSON/JSONB path expression.
The column is quoted via quote_identifier and embedded single quotes
in path elements are escaped (' -> ''). Pass trusted identifiers
only, not arbitrary user input.
Sourcepub async fn has_extension(pool: &PgPool, extension: &str) -> SqlxResult<bool>
pub async fn has_extension(pool: &PgPool, extension: &str) -> SqlxResult<bool>
Check if a PostgreSQL extension is available.
Sourcepub async fn version(pool: &PgPool) -> SqlxResult<String>
pub async fn version(pool: &PgPool) -> SqlxResult<String>
Get PostgreSQL version.
Auto Trait Implementations§
impl Freeze for PgHelpers
impl RefUnwindSafe for PgHelpers
impl Send for PgHelpers
impl Sync for PgHelpers
impl Unpin for PgHelpers
impl UnsafeUnpin for PgHelpers
impl UnwindSafe for PgHelpers
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more