Struct lumus_sql_builder::sqlite::Where

source ·
pub struct Where { /* private fields */ }
Expand description

Represents a WHERE clause builder for SQL queries.

Implementations§

source§

impl Where

source

pub fn new() -> Self

Creates a new Where instance with an empty statement.

§Example
use lumus_sql_builder::sqlite::Where;

let mut condition = Where::new();
condition.equal_to("name", "Dayvson Spacca");

assert_eq!(condition.build(), "name = 'Dayvson Spacca'")
source

pub fn from(statement: &str) -> Self

Creates a new Where instance with a specified initial statement.

§Example
use lumus_sql_builder::sqlite::Where;

let mut condition = Where::from("name = 'Dayvson Spacca'");
condition.and().greater_than("age", "21");

assert_eq!(condition.build(), "name = 'Dayvson Spacca' AND age > '21'");
source

pub fn equal_to(&mut self, field: &str, value: &str) -> &mut Self

Adds an equality condition (field = value) to the WHERE clause.

source

pub fn not_equal_to(&mut self, field: &str, value: &str) -> &mut Self

Adds a not equal condition (field != value) to the WHERE clause.

source

pub fn greater_than(&mut self, field: &str, value: &str) -> &mut Self

Adds a greater than condition (field > value) to the WHERE clause.

source

pub fn greater_than_equal(&mut self, field: &str, value: &str) -> &mut Self

Adds a greater than or equal condition (field >= value) to the WHERE clause.

source

pub fn less_than(&mut self, field: &str, value: &str) -> &mut Self

Adds a less than condition (field < value) to the WHERE clause.

source

pub fn less_than_equal( &mut self, field: &str, value: &str, ) -> Result<&mut Self, SqlBuilderError>

Adds a less than or equal condition (field <= value) to the WHERE clause.

source

pub fn is_null(&mut self, field: &str) -> &mut Self

Adds a IS NULL condition (field IS NULL) to the WHERE clause.

source

pub fn is_not_null(&mut self, field: &str) -> &mut Self

Adds a IS NOT NULL condition (field IS NOT NULL) to the WHERE clause.

source

pub fn inside(&mut self, field: &str, values: Vec<&str>) -> &mut Self

Adds an IN condition (field IN (values)) to the WHERE clause.

source

pub fn not_inside(&mut self, field: &str, values: Vec<&str>) -> &mut Self

Adds a NOT IN condition (field NOT IN (values)) to the WHERE clause.

source

pub fn like(&mut self, field: &str, value: &str) -> &mut Self

Adds a LIKE condition (field LIKE value) to the WHERE clause.

source

pub fn not_like(&mut self, field: &str, value: &str) -> &mut Self

Adds a NOT LIKE condition (field NOT LIKE value) to the WHERE clause.

source

pub fn and(&mut self) -> &mut Self

Appends AND to the current statement in the WHERE clause.

source

pub fn or(&mut self) -> &mut Self

Appends OR to the current statement in the WHERE clause.

source

pub fn nest(&mut self) -> &mut Self

Appends a left parenthesis ( to the current statement in the WHERE clause.

source

pub fn unnest(&mut self) -> &mut Self

Appends a right parenthesis ) to the current statement in the WHERE clause.

source

pub fn build(&self) -> String

Constructs and returns the final SQL statement represented by the WHERE clause.

Trait Implementations§

source§

impl Debug for Where

source§

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

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

impl Display for Where

Implementation of the Display trait for Where, allowing it to be printed.

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Where

§

impl RefUnwindSafe for Where

§

impl Send for Where

§

impl Sync for Where

§

impl Unpin for Where

§

impl UnwindSafe for Where

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§

default 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>,

§

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>,

§

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.