[][src]Struct quaint::ast::Update

pub struct Update<'a> { /* fields omitted */ }

A builder for an UPDATE statement.

Methods

impl<'a> Update<'a>[src]

pub fn table<T>(table: T) -> Self where
    T: Into<Table<'a>>, 
[src]

Creates the basis for an UPDATE statement to the given table.

pub fn set<K, V>(self, column: K, value: V) -> Update<'a> where
    K: Into<Column<'a>>,
    V: Into<DatabaseValue<'a>>, 
[src]

Add another column value assignment to the query

let query = Update::table("users").set("foo", 10).set("bar", false);
let (sql, params) = Sqlite::build(query);

assert_eq!("UPDATE `users` SET `foo` = ?, `bar` = ?", sql);

assert_eq!(
    vec![
        ParameterizedValue::Integer(10),
        ParameterizedValue::Boolean(false),
    ],
    params,
);

pub fn so_that<T>(self, conditions: T) -> Self where
    T: Into<ConditionTree<'a>>, 
[src]

Adds WHERE conditions to the query. See Comparable for more examples.

let query = Update::table("users").set("foo", 1).so_that("bar".equals(false));
let (sql, params) = Sqlite::build(query);

assert_eq!("UPDATE `users` SET `foo` = ? WHERE `bar` = ?", sql);

assert_eq!(
    vec![
        ParameterizedValue::Integer(1),
        ParameterizedValue::Boolean(false),
    ],
    params,
);

We can also use a nested SELECT in the conditions.

let select = Select::from_table("bars").column("id").so_that("uniq_val".equals(3));
let query = Update::table("users").set("foo", 1).so_that("bar".equals(select));
let (sql, params) = Sqlite::build(query);

assert_eq!(
    "UPDATE `users` SET `foo` = ? WHERE `bar` = (SELECT `id` FROM `bars` WHERE `uniq_val` = ?)",
    sql
);

assert_eq!(
    vec![
        ParameterizedValue::Integer(1),
        ParameterizedValue::Integer(3),
    ],
    params,
);

Trait Implementations

impl<'a> Clone for Update<'a>[src]

impl<'a> Debug for Update<'a>[src]

impl<'a> From<Update<'a>> for Query<'a>[src]

impl<'a> PartialEq<Update<'a>> for Update<'a>[src]

impl<'a> StructuralPartialEq for Update<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Update<'a>

impl<'a> Send for Update<'a>

impl<'a> Sync for Update<'a>

impl<'a> Unpin for Update<'a>

impl<'a> UnwindSafe for Update<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,