[−][src]Struct quaint::ast::Update
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]
T: Into<Table<'a>>,
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]
K: Into<Column<'a>>,
V: Into<DatabaseValue<'a>>,
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]
T: Into<ConditionTree<'a>>,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,