Remove a bunch of redundant parens
This commit is contained in:
parent
1ebd158da1
commit
9a1073aae2
@ -160,7 +160,7 @@ impl QueryBuilder {
|
|||||||
/// // Search for a value that has "foo" in it
|
/// // Search for a value that has "foo" in it
|
||||||
/// qb.like("field", String::from("foo"), LikeWildcard::Both);
|
/// qb.like("field", String::from("foo"), LikeWildcard::Both);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn like(&mut self, field: &str, value: (impl Any), position: LikeWildcard) -> &mut Self {
|
pub fn like(&mut self, field: &str, value: impl Any, position: LikeWildcard) -> &mut Self {
|
||||||
self._like(field, value, position, "LIKE", "AND")
|
self._like(field, value, position, "LIKE", "AND")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ impl QueryBuilder {
|
|||||||
pub fn or_like(
|
pub fn or_like(
|
||||||
&mut self,
|
&mut self,
|
||||||
field: &str,
|
field: &str,
|
||||||
value: (impl Any),
|
value: impl Any,
|
||||||
position: LikeWildcard,
|
position: LikeWildcard,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
self._like(field, value, position, "LIKE", "OR")
|
self._like(field, value, position, "LIKE", "OR")
|
||||||
@ -178,7 +178,7 @@ impl QueryBuilder {
|
|||||||
pub fn not_like(
|
pub fn not_like(
|
||||||
&mut self,
|
&mut self,
|
||||||
field: &str,
|
field: &str,
|
||||||
value: (impl Any),
|
value: impl Any,
|
||||||
position: LikeWildcard,
|
position: LikeWildcard,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
self._like(field, value, position, "NOT LIKE", "AND")
|
self._like(field, value, position, "NOT LIKE", "AND")
|
||||||
@ -188,7 +188,7 @@ impl QueryBuilder {
|
|||||||
pub fn or_not_like(
|
pub fn or_not_like(
|
||||||
&mut self,
|
&mut self,
|
||||||
field: &str,
|
field: &str,
|
||||||
value: (impl Any),
|
value: impl Any,
|
||||||
position: LikeWildcard,
|
position: LikeWildcard,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
self._like(field, value, position, "NOT LIKE", "OR")
|
self._like(field, value, position, "NOT LIKE", "OR")
|
||||||
@ -209,12 +209,12 @@ impl QueryBuilder {
|
|||||||
/// // Other operators can be used with a separating space
|
/// // Other operators can be used with a separating space
|
||||||
/// qb.having("clues >=", vec![Box::new(4)]);
|
/// qb.having("clues >=", vec![Box::new(4)]);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn having(&mut self, key: &str, value: Vec<(impl Any)>) -> &mut Self {
|
pub fn having(&mut self, key: &str, value: Vec<impl Any>) -> &mut Self {
|
||||||
self._having(key, value, "AND")
|
self._having(key, value, "AND")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a `having` clause to the query, prefixed with an `or`
|
/// Add a `having` clause to the query, prefixed with an `or`
|
||||||
pub fn or_having(&mut self, key: &str, value: Vec<(impl Any)>) -> &mut Self {
|
pub fn or_having(&mut self, key: &str, value: Vec<impl Any>) -> &mut Self {
|
||||||
self._having(key, value, "OR")
|
self._having(key, value, "OR")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,11 +222,6 @@ impl QueryBuilder {
|
|||||||
// ! 'Where' methods
|
// ! 'Where' methods
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
/// Alias method for `r#where`.
|
|
||||||
pub fn filter(&mut self, key: &str, value: (impl Any)) -> &mut Self {
|
|
||||||
self.r#where(key, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Specify a condition for the `where` clause of the query. Can be called
|
/// Specify a condition for the `where` clause of the query. Can be called
|
||||||
/// multiple times, which will then add additional where conditions, prefixed
|
/// multiple times, which will then add additional where conditions, prefixed
|
||||||
/// with 'AND'.
|
/// with 'AND'.
|
||||||
@ -240,32 +235,38 @@ impl QueryBuilder {
|
|||||||
/// // Other operators can be used with a separating space
|
/// // Other operators can be used with a separating space
|
||||||
/// qb.r#where("key >", Box::new(4));
|
/// qb.r#where("key >", Box::new(4));
|
||||||
/// ```
|
/// ```
|
||||||
pub fn r#where(&mut self, key: &str, value: (impl Any)) -> &mut Self {
|
pub fn r#where(&mut self, key: &str, value: impl Any) -> &mut Self {
|
||||||
self._where_string(key, value, "AND")
|
self._where_string(key, value, "AND")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Alias method for `where`, as using the `where` method requires
|
||||||
|
/// using the raw identifier `r#where`.
|
||||||
|
pub fn filter(&mut self, key: &str, value: impl Any) -> &mut Self {
|
||||||
|
self.r#where(key, value)
|
||||||
|
}
|
||||||
|
|
||||||
/// Specify a condition for the `where` clause of the query, prefixed with `or`
|
/// Specify a condition for the `where` clause of the query, prefixed with `or`
|
||||||
pub fn or_where(&mut self, key: &str, value: (impl Any)) -> &mut Self {
|
pub fn or_where(&mut self, key: &str, value: impl Any) -> &mut Self {
|
||||||
self._where_string(key, value, "OR")
|
self._where_string(key, value, "OR")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Specify a `where in` clause for the query
|
/// Specify a `where in` clause for the query
|
||||||
pub fn where_in(&mut self, key: &str, values: Vec<(impl Any)>) -> &mut Self {
|
pub fn where_in(&mut self, key: &str, values: Vec<impl Any>) -> &mut Self {
|
||||||
self._where_in(key, values, "IN", "AND")
|
self._where_in(key, values, "IN", "AND")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Specify a `where in` clause for the query, prefixed with `or`
|
/// Specify a `where in` clause for the query, prefixed with `or`
|
||||||
pub fn or_where_in(&mut self, key: &str, values: Vec<(impl Any)>) -> &mut Self {
|
pub fn or_where_in(&mut self, key: &str, values: Vec<impl Any>) -> &mut Self {
|
||||||
self._where_in(key, values, "IN", "OR")
|
self._where_in(key, values, "IN", "OR")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Specify a `where not in` clause for the query
|
/// Specify a `where not in` clause for the query
|
||||||
pub fn where_not_in(&mut self, key: &str, values: Vec<(impl Any)>) -> &mut Self {
|
pub fn where_not_in(&mut self, key: &str, values: Vec<impl Any>) -> &mut Self {
|
||||||
self._where_in(key, values, "NOT IN", "AND")
|
self._where_in(key, values, "NOT IN", "AND")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Specify a `where not in` clause for the query, prefixed with `or`
|
/// Specify a `where not in` clause for the query, prefixed with `or`
|
||||||
pub fn or_where_not_in(&mut self, key: &str, values: Vec<(impl Any)>) -> &mut Self {
|
pub fn or_where_not_in(&mut self, key: &str, values: Vec<impl Any>) -> &mut Self {
|
||||||
self._where_in(key, values, "NOT IN", "OR")
|
self._where_in(key, values, "NOT IN", "OR")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +275,7 @@ impl QueryBuilder {
|
|||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
/// Set a key and value for an insert or update query
|
/// Set a key and value for an insert or update query
|
||||||
pub fn set(&mut self, key: &str, value: (impl Any)) -> &mut Self {
|
pub fn set(&mut self, key: &str, value: impl Any) -> &mut Self {
|
||||||
// @TODO figure a way to make this easier to use
|
// @TODO figure a way to make this easier to use
|
||||||
let key = self.driver.quote_identifier(key);
|
let key = self.driver.quote_identifier(key);
|
||||||
self.state.append_set_array_keys(&key).append_values(Box::new(value));
|
self.state.append_set_array_keys(&key).append_values(Box::new(value));
|
||||||
@ -283,7 +284,7 @@ impl QueryBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Set a map of data for an insert or update query
|
/// Set a map of data for an insert or update query
|
||||||
pub fn set_map(&mut self, data: HashMap<String, (impl Any)>) -> &mut Self {
|
pub fn set_map(&mut self, data: HashMap<String, impl Any>) -> &mut Self {
|
||||||
for (key, value) in data {
|
for (key, value) in data {
|
||||||
self.set(&key, value);
|
self.set(&key, value);
|
||||||
}
|
}
|
||||||
@ -514,7 +515,7 @@ impl QueryBuilder {
|
|||||||
fn _like(
|
fn _like(
|
||||||
&mut self,
|
&mut self,
|
||||||
field: &str,
|
field: &str,
|
||||||
value: (impl Any),
|
value: impl Any,
|
||||||
position: LikeWildcard,
|
position: LikeWildcard,
|
||||||
like: &str,
|
like: &str,
|
||||||
conj: &str,
|
conj: &str,
|
||||||
@ -540,7 +541,7 @@ impl QueryBuilder {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn _having(&mut self, key: &str, values: Vec<(impl Any)>, conj: &str) -> &mut Self {
|
fn _having(&mut self, key: &str, values: Vec<impl Any>, conj: &str) -> &mut Self {
|
||||||
let keys = self._where(key, values);
|
let keys = self._where(key, values);
|
||||||
|
|
||||||
for k in keys {
|
for k in keys {
|
||||||
@ -568,7 +569,7 @@ impl QueryBuilder {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn _where(&mut self, key: &str, values: Vec<(impl Any)>) -> Vec<String> {
|
fn _where(&mut self, key: &str, values: Vec<impl Any>) -> Vec<String> {
|
||||||
for x in values {
|
for x in values {
|
||||||
self.state.append_where_values(Box::new(x));
|
self.state.append_where_values(Box::new(x));
|
||||||
}
|
}
|
||||||
@ -579,7 +580,7 @@ impl QueryBuilder {
|
|||||||
fn _where_in(
|
fn _where_in(
|
||||||
&mut self,
|
&mut self,
|
||||||
key: &str,
|
key: &str,
|
||||||
values: Vec<(impl Any)>,
|
values: Vec<impl Any>,
|
||||||
in_str: &str,
|
in_str: &str,
|
||||||
conj: &str,
|
conj: &str,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
|
Loading…
Reference in New Issue
Block a user