Skip to main content

ValuesQuery

Struct ValuesQuery 

Source
pub struct ValuesQuery {
    pub with: With,
    pub values: Values,
    pub order_by: OrderBy,
    pub limit: Limit,
    pub offset: Offset,
    pub fetch: Fetch,
    pub combines: Combines,
}
Expand description

A standalone PostgreSQL VALUES statement.

From https://www.postgresql.org/docs/17/sql-values.html:

VALUES ( expression [, ...] ) [, ...]
    [ ORDER BY sort_expression [ ASC | DESC | USING operator ] [, ...] ]
    [ LIMIT { count | ALL } ]
    [ OFFSET start [ ROW | ROWS ] ]
    [ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } { ONLY | WITH TIES } ]

VALUES is a simple_select alternative in gram.y, so it also takes a leading WITH and participates in set operations — VALUES (1) UNION SELECT … — and the tail clauses of a combination live in Combines, as they do for a SELECT. The columns of the result are named column1, column2, …, which is what an ORDER BY here refers to (or ORDER BY 1).

It has no FOR UPDATE: PostgreSQL rejects a locking clause on VALUES, so HasLocks is not implemented and values::for_update does not exist.

The rows are the same Values clause an INSERT holds, minus its query alternative: a standalone VALUES is rows, so a Values::query set here is a recorded build error rather than something to render around.

Fields§

§with: With

WITH ….

§values: Values

The rows.

§order_by: OrderBy

ORDER BY … — this statement’s own.

§limit: Limit

LIMIT … — this statement’s own.

§offset: Offset

OFFSET … — this statement’s own.

§fetch: Fetch

FETCH … — this statement’s own.

§combines: Combines

The set operations, and the trailing clauses that belong to their result.

Implementations§

Source§

impl ValuesQuery

Source

pub fn new() -> ValuesQuery

A VALUES with no rows yet — which does not build until it has one.

Source

pub fn apply(&mut self, mods: impl Mod<ValuesQuery>)

Apply more mods to an existing query.

Trait Implementations§

Source§

impl Clone for ValuesQuery

Source§

fn clone(&self) -> ValuesQuery

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ValuesQuery

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ValuesQuery

Source§

fn default() -> ValuesQuery

Returns the “default value” for a type. Read more
Source§

impl Expression for ValuesQuery

Source§

fn write_sql(&self, w: &mut SqlWriter<'_>)

Append this fragment to w. Read more
Source§

impl HasCombines for ValuesQuery

Source§

fn combines_mut(&mut self) -> &mut Combines

The set operations to modify.
Source§

impl HasFetch for ValuesQuery

Source§

fn fetch_mut(&mut self) -> &mut Fetch

The FETCH clause to modify.
Source§

impl HasLimit for ValuesQuery

Source§

fn limit_mut(&mut self) -> &mut Limit

The LIMIT clause to modify.
Source§

impl HasOffset for ValuesQuery

Source§

fn offset_mut(&mut self) -> &mut Offset

The OFFSET clause to modify.
Source§

impl HasOrderBy for ValuesQuery

Source§

fn order_by_mut(&mut self) -> &mut OrderBy

The ORDER BY clause to modify.
Source§

impl HasValues for ValuesQuery

Source§

fn values_mut(&mut self) -> &mut Values

The row source to modify.
Source§

impl HasWith for ValuesQuery

Source§

fn with_mut(&mut self) -> &mut With

The WITH clause to modify.
Source§

impl IntoExpr for ValuesQuery

Source§

fn into_expr(self) -> Expr

Perform the conversion.
Source§

impl IntoExprList for ValuesQuery

Source§

fn into_expr_list(self) -> Vec<Expr>

Perform the conversion.
Source§

impl Query for ValuesQuery

Source§

fn query_type(&self) -> QueryType

Which statement this renders.
Source§

fn dialect(&self) -> &dyn Dialect

The dialect this query renders itself in. Read more
Source§

fn build(&self) -> Result<(String, Vec<Value>), Error>

Render to SQL and arguments, numbering placeholders from 1. Read more
Source§

fn build_from(&self, start: usize) -> Result<(String, Vec<Value>), Error>

build with a different first placeholder position, for splicing into a statement that already has arguments — bob’s BuildN.
Source§

impl<H, L, M> QueryExtensions<H, L, M> for ValuesQuery

Source§

fn hooks(&self) -> &[Hook]

Hooks to run before this query executes.
Source§

fn loaders(&self) -> &[Loader]

Loaders to run after this query executes, for eagerly loaded relations.
Source§

fn mapper_mods(&self) -> &[MapperMod]

Adjustments to the row mapper, for relations loaded in the same query.

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.