Struct scooby::postgres::statements::Update
source · pub struct Update { /* private fields */ }
Expand description
UPDATE
statement with at least one set of values, and possibly additional clauses.
Finalize and turn into String
by calling to_string
.
See update
docs for more details and examples.
Implementations§
source§impl Update
impl Update
sourcepub fn set(
self,
column: impl Into<Column>,
value: impl Into<Expression>
) -> Self
pub fn set( self, column: impl Into<Column>, value: impl Into<Expression> ) -> Self
Add a column + expression pair to the SET
clause of this statement
use scooby::postgres::update;
let sql = update("Dummy").set("x", "$1").set("y", "$2").to_string();
assert_eq!(sql, "UPDATE Dummy SET x = $1, y = $2");
sourcepub fn where_(self, conditions: impl IntoIteratorOfSameType<Condition>) -> Self
pub fn where_(self, conditions: impl IntoIteratorOfSameType<Condition>) -> Self
Add one or more WHERE
conditions, AND
’ed together with themselves and existing conditions.
use scooby::postgres::update;
let sql = update("Dummy")
.set("x", "y + z")
.where_(("x > 1", "y > 1"))
.where_("z > 1")
.to_string();
assert_eq!(sql, "UPDATE Dummy SET x = y + z WHERE x > 1 AND y > 1 AND z > 1");
sourcepub fn returning(
self,
expressions: impl IntoIteratorOfSameType<OutputExpression>
) -> Self
pub fn returning( self, expressions: impl IntoIteratorOfSameType<OutputExpression> ) -> Self
Add one or more RETURNING
expressions.
use scooby::postgres::update;
let sql = update("Dummy")
.set("x", "$1")
.returning("id")
.returning(("width", "height"))
.to_string();
assert_eq!(sql, "UPDATE Dummy SET x = $1 RETURNING id, width, height");
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Update
impl Send for Update
impl Sync for Update
impl Unpin for Update
impl UnwindSafe for Update
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