Reformat code

This commit is contained in:
Timothy Warren 2019-04-17 12:58:05 -04:00
parent b4a21d189f
commit 1e7644108b
3 changed files with 10 additions and 42 deletions

View File

@ -26,12 +26,7 @@ pub mod prelude {
//! This includes enum types, traits,
//! the Query Builder, and individual database drivers.
pub use crate::drivers::DatabaseDriver;
pub use crate::query_builder::{
LikeWildcard,
JoinType,
OrderDirection,
QueryBuilder
};
pub use crate::query_builder::{JoinType, LikeWildcard, OrderDirection, QueryBuilder};
#[cfg(feature = "postgres")]
/// Postgres Driver

View File

@ -226,22 +226,12 @@ impl QueryBuilder {
}
/// Generates an OR Like clause
pub fn or_like(
&mut self,
field: &str,
value: impl Any,
position: LikeWildcard,
) -> &mut Self {
pub fn or_like(&mut self, field: &str, value: impl Any, position: LikeWildcard) -> &mut Self {
self._like(field, value, position, "LIKE", "OR")
}
/// Generates a NOI Like clause
pub fn not_like(
&mut self,
field: &str,
value: impl Any,
position: LikeWildcard,
) -> &mut Self {
pub fn not_like(&mut self, field: &str, value: impl Any, position: LikeWildcard) -> &mut Self {
self._like(field, value, position, "NOT LIKE", "AND")
}
@ -339,7 +329,9 @@ impl QueryBuilder {
pub fn set(&mut self, key: &str, value: impl Any) -> &mut Self {
// @TODO figure a way to make this easier to use
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));
self
}
@ -1013,14 +1005,8 @@ mod tests {
let mut qb = QueryBuilder::default();
let mut authors = HashMap::new();
authors.insert(
String::from("Chinua Achebe"),
String::from("Nigeria"),
);
authors.insert(
String::from("Rabindranath Tagore"),
String::from("India"),
);
authors.insert(String::from("Chinua Achebe"), String::from("Nigeria"));
authors.insert(String::from("Rabindranath Tagore"), String::from("India"));
authors.insert(String::from("Anita Nair"), String::from("India"));
qb.set_map(authors);
@ -1034,17 +1020,7 @@ mod tests {
fn set_where_in() {
let mut qb = QueryBuilder::default();
qb.from("test").where_in(
"foo",
vec![
0,
1,
2,
3,
4,
5,
],
);
qb.from("test").where_in("foo", vec![0, 1, 2, 3, 4, 5]);
let sql = qb.get_compiled_select();
let expected = "SELECT *\nFROM \"test\" WHERE \"foo\" IN (?,?,?,?,?,?) ";

View File

@ -51,10 +51,7 @@ fn select_without_from() {
fn select_where_in() {
let mut qb = QueryBuilder::default();
qb.from("test").where_in(
"foo",
vec![0, 1, 2, 3, 4, 5],
);
qb.from("test").where_in("foo", vec![0, 1, 2, 3, 4, 5]);
let sql = qb.get_compiled_select();
let expected = "SELECT *\nFROM \"test\" WHERE \"foo\" IN (?,?,?,?,?,?) ";