Struct WhereClause

Source
pub struct WhereClause<'a, 'b> { /* private fields */ }
Expand description

Struct representing an WHERE-Clause

Implementations§

Source§

impl<'a, 'b> WhereClause<'a, 'b>

Source

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.

Source

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'")
Source

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'")
Source

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>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, 'b> Display for WhereClause<'a, 'b>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FormatResult

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.