From 1e7644108b5812c79e5a7353716b84f1cd914890 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 17 Apr 2019 12:58:05 -0400 Subject: [PATCH] Reformat code --- src/lib.rs | 7 +------ src/query_builder.rs | 40 ++++++++------------------------------- tests/integration_test.rs | 5 +---- 3 files changed, 10 insertions(+), 42 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7b43714..44ef72b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 diff --git a/src/query_builder.rs b/src/query_builder.rs index c8f2a64..a0e1385 100644 --- a/src/query_builder.rs +++ b/src/query_builder.rs @@ -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 (?,?,?,?,?,?) "; diff --git a/tests/integration_test.rs b/tests/integration_test.rs index 50fa445..24abbb3 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -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 (?,?,?,?,?,?) ";