pub struct WhereClause<'a, 'b> { /* private fields */ }
Expand description
Struct representing an WHERE-Clause
Implementations§
Source§impl<'a, 'b> WhereClause<'a, 'b>
impl<'a, 'b> WhereClause<'a, 'b>
Sourcepub fn new(
table: &'a str,
cond: Value<'b>,
how: Option<Condition>,
) -> WhereClause<'a, 'b>
pub fn new( table: &'a str, cond: Value<'b>, how: Option<Condition>, ) -> WhereClause<'a, 'b>
Creates a new WHERE-clause
If the Value of how
is none when initializing the clause, Condition::And
is assumed and used for the clause.
Note: If the WhereClause
is the first one to be inserted in the string of an query,
the condition will be left out.
Sourcepub fn as_string(&self) -> String
pub fn as_string(&self) -> String
Returns a String
representing the WhereClause
with it’s condition part
The returned String
is also the default representation returned when calling the
Display
trait functions on this struct.
§Example
use query_builder::{WhereClause, Condition, Value};
let wclause = WhereClause::new("user", Value::Varchar("gerald"), Some(Condition::Or));
assert_eq!(wclause.as_string(), "OR user = 'gerald'")
Sourcepub fn as_string_no_cond_with_prefix(&self) -> String
pub fn as_string_no_cond_with_prefix(&self) -> String
Returns a String
representing the WhereClause
without it’s condition part
but with the WHERE
phrase in the beginning
§Example
use query_builder::{WhereClause, Value};
let clause = WhereClause::new("user", Value::Varchar("thomas"), None);
assert_eq!(clause.as_string_no_cond_with_prefix(), "WHERE user = 'thomas'")
Sourcepub fn as_string_no_cond(&self) -> String
pub fn as_string_no_cond(&self) -> String
Returns a String
representing the WhereClause
without WHERE
prefix and
without it’s conditional parts
§Example
use query_builder::{WhereClause, Value};
let clause = WhereClause::new("user", Value::Varchar("jeanny"), None);
assert_eq!(clause.as_string_no_cond(), "user = 'jeanny'")
Trait Implementations§
Source§impl<'a, 'b> Debug for WhereClause<'a, 'b>
impl<'a, 'b> Debug for WhereClause<'a, 'b>
Source§impl<'a, 'b> Display for WhereClause<'a, 'b>
impl<'a, 'b> Display for WhereClause<'a, 'b>
Auto Trait Implementations§
impl<'a, 'b> Freeze for WhereClause<'a, 'b>
impl<'a, 'b> RefUnwindSafe for WhereClause<'a, 'b>
impl<'a, 'b> Send for WhereClause<'a, 'b>
impl<'a, 'b> Sync for WhereClause<'a, 'b>
impl<'a, 'b> Unpin for WhereClause<'a, 'b>
impl<'a, 'b> UnwindSafe for WhereClause<'a, 'b>
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