pub struct UpdateSets { /* private fields */ }
Expand description
Represents a collection of update sets.
Update sets are used to define the values to be updated in a database table.
§Example
use safety_postgres::access::sql_base::UpdateSets;
let mut update_sets = UpdateSets::new();
update_sets.add_set("column1", "value1").expect("adding update set failed");
update_sets.add_set("column2", "value2").expect("adding update set failed");
let update_set_text = update_sets.get_update_text();
assert_eq!(update_set_text, "UPDATE main_table_name SET column1 = value1, column2 = value2");
Implementations§
Source§impl UpdateSets
impl UpdateSets
Sourcepub fn add_set(
&mut self,
column: &str,
value: &str,
) -> Result<&mut Self, UpdateSetError>
pub fn add_set( &mut self, column: &str, value: &str, ) -> Result<&mut Self, UpdateSetError>
Adds a set of column-value pair to the update sets of the struct.
§Arguments
column
- The name of the column to be updated.value
- The new value for the column.
§Errors
Returns an UpdateSetError
if the column
is not a valid string.
§Returns
A mutable reference to Self (UpdateSets)
on success.
§Example
use safety_postgres::access::sql_base::UpdateSets;
let mut update_sets = UpdateSets::new();
update_sets.add_set("name", "John").expect("adding update set failed");
Sourcepub fn get_update_text(&self) -> String
pub fn get_update_text(&self) -> String
Returns the update text for the set parameters.
Sourcepub fn get_num_values(&self) -> usize
pub fn get_num_values(&self) -> usize
Trait Implementations§
Source§impl Clone for UpdateSets
impl Clone for UpdateSets
Source§fn clone(&self) -> UpdateSets
fn clone(&self) -> UpdateSets
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for UpdateSets
impl RefUnwindSafe for UpdateSets
impl Send for UpdateSets
impl Sync for UpdateSets
impl Unpin for UpdateSets
impl UnwindSafe for UpdateSets
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