Struct query_builder::UpdateQuery
[−]
[src]
pub struct UpdateQuery<'a, 'c> { pub set: BTreeMap<&'a str, Value<'c>>, pub whre: Vec<WhereClause<'a, 'c>>, // some fields omitted }
Struct representing an SQL Update statement
Fields
set: BTreeMap<&'a str, Value<'c>>
A Map containing the field to set with the appropiate values to them
whre: Vec<WhereClause<'a, 'c>>
All WhereClause
s for conditional Updating in this
UpdateQuery
Methods
impl<'a, 'c> UpdateQuery<'a, 'c>
[src]
pub fn update(table: &'a str) -> UpdateQuery
[src]
Returns a new UpdateQuery
that updates the table table
Example
use query_builder::UpdateQuery; let query = UpdateQuery::update("town"); assert_eq!(query.as_string(), "UPDATE town");
pub fn limit(&mut self, l: usize)
[src]
Set the limit of the Query to the value of l
Example
use query_builder::{UpdateQuery, Value}; let mut query = UpdateQuery::update("users"); // set the limit query.limit(12); // assert that the limit is actually there assert_eq!(query.get_limit(), Some(12))
pub fn has_limit(&self) -> bool
[src]
Returns whether or not the UpdateQuery
has a limit
Example
use query_builder::UpdateQuery; // create the query let mut query = UpdateQuery::update("cities"); assert_eq!(query.has_limit(), false); // set limit query.limit(1); assert_eq!(query.has_limit(), true);
pub fn get_limit(&self) -> Option<usize>
[src]
Returns the limit of the UpdateQuery
if there is one
Example
use query_builder::UpdateQuery; // create the query let mut query = UpdateQuery::update("countries"); assert_eq!(query.get_limit(), None); // set the limit query.limit(12); assert_eq!(query.get_limit(), Some(12));
pub fn as_string(&self) -> String
[src]
Returns the String
representation of the UpdateQuery
Example
use query_builder::{UpdateQuery, Value}; let mut query = UpdateQuery::update("users"); query.set.insert("name", Value::Varchar("jeff")); query.limit(1); assert_eq!(query.as_string(),"UPDATE users SET name = 'jeff' LIMIT 1");
Trait Implementations
impl<'a, 'c> Debug for UpdateQuery<'a, 'c>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<'a, 'c> Display for UpdateQuery<'a, 'c>
[src]
fn fmt(&self, f: &mut Formatter) -> FormatResult
[src]
Formats the value using the given formatter. Read more