pub struct Where { /* private fields */ }
Expand description
Represents a WHERE clause builder for SQL queries.
Implementations§
Source§impl Where
impl Where
Sourcepub fn new() -> Self
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'")
Sourcepub fn from(statement: &str) -> Self
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'");
Sourcepub fn equal_to(&mut self, field: &str, value: &str) -> &mut Self
pub fn equal_to(&mut self, field: &str, value: &str) -> &mut Self
Adds an equality condition (field = value
) to the WHERE clause.
Sourcepub fn not_equal_to(&mut self, field: &str, value: &str) -> &mut Self
pub fn not_equal_to(&mut self, field: &str, value: &str) -> &mut Self
Adds a not equal condition (field != value
) to the WHERE clause.
Sourcepub fn greater_than(&mut self, field: &str, value: &str) -> &mut Self
pub fn greater_than(&mut self, field: &str, value: &str) -> &mut Self
Adds a greater than condition (field > value
) to the WHERE clause.
Sourcepub fn greater_than_equal(&mut self, field: &str, value: &str) -> &mut Self
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.
Sourcepub fn less_than(&mut self, field: &str, value: &str) -> &mut Self
pub fn less_than(&mut self, field: &str, value: &str) -> &mut Self
Adds a less than condition (field < value
) to the WHERE clause.
Sourcepub fn less_than_equal(&mut self, field: &str, value: &str) -> &mut Self
pub fn less_than_equal(&mut self, field: &str, value: &str) -> &mut Self
Adds a less than or equal condition (field <= value
) to the WHERE clause.
Sourcepub fn is_null(&mut self, field: &str) -> &mut Self
pub fn is_null(&mut self, field: &str) -> &mut Self
Adds a IS NULL
condition (field IS NULL
) to the WHERE clause.
Sourcepub fn is_not_null(&mut self, field: &str) -> &mut Self
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.
Sourcepub fn inside(&mut self, field: &str, values: Vec<&str>) -> &mut Self
pub fn inside(&mut self, field: &str, values: Vec<&str>) -> &mut Self
Adds an IN
condition (field IN (values)
) to the WHERE clause.
Sourcepub fn not_inside(&mut self, field: &str, values: Vec<&str>) -> &mut Self
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.
Sourcepub fn like(&mut self, field: &str, value: &str) -> &mut Self
pub fn like(&mut self, field: &str, value: &str) -> &mut Self
Adds a LIKE
condition (field LIKE value
) to the WHERE clause.
Sourcepub fn not_like(&mut self, field: &str, value: &str) -> &mut Self
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.
Sourcepub fn nest(&mut self) -> &mut Self
pub fn nest(&mut self) -> &mut Self
Appends a left parenthesis (
to the current statement in the WHERE clause.