From dc28318a3f8638f7036fe190deedb3db64e04ca9 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 17 Apr 2019 12:01:46 -0400 Subject: [PATCH] Hide more things --- src/enums.rs | 63 -------------------------------------------- src/lib.rs | 9 ++++--- src/query_builder.rs | 63 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 68 insertions(+), 67 deletions(-) delete mode 100644 src/enums.rs diff --git a/src/enums.rs b/src/enums.rs deleted file mode 100644 index b247697..0000000 --- a/src/enums.rs +++ /dev/null @@ -1,63 +0,0 @@ -//! Common enums - -/// The position of the wildcard(s) -/// for a `like` clause -#[derive(Debug)] -pub enum LikeWildcard { - /// Wildcard before search term - /// eg. `%foo` - Before, - - /// Wildcard after the search term - /// eg. `foo%` - After, - - /// Wildcards surrounding the search term - /// eg. `%foo%` - Both, -} - -/// The type of SQL join -#[derive(Debug)] -pub enum JoinType { - /// A `CROSS` join - Cross, - /// An `INNER` join - Inner, - /// An `OUTER` join - Outer, - /// A `LEFT (OUTER)` join - Left, - /// A `RIGHT (OUTER)` join - Right, -} - -/// The sort direction -#[derive(Debug, PartialEq)] -pub enum OrderDirection { - /// Sort Ascending - Asc, - /// Sort Descending - Desc, - /// Random Sort (Not yet implemented!) - Rand, -} - -/// The type of Query Clause -#[derive(Debug, PartialEq)] -pub enum QueryClauseType { - /// Ending a parenthetical grouping - GroupEnd, - /// Starting a parenthetical grouping - GroupStart, - /// A having clause - Having, - /// A join clause - Join, - /// A like clause - Like, - /// A where clause - Where, - /// A where in clause - WhereIn, -} diff --git a/src/lib.rs b/src/lib.rs index ced0e93..7b43714 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,7 +17,6 @@ extern crate lazy_static; pub mod drivers; -pub mod enums; pub mod fns; pub mod query_builder; @@ -27,8 +26,12 @@ pub mod prelude { //! This includes enum types, traits, //! the Query Builder, and individual database drivers. pub use crate::drivers::DatabaseDriver; - pub use crate::enums::*; - pub use crate::query_builder::QueryBuilder; + pub use crate::query_builder::{ + LikeWildcard, + JoinType, + OrderDirection, + QueryBuilder + }; #[cfg(feature = "postgres")] /// Postgres Driver diff --git a/src/query_builder.rs b/src/query_builder.rs index e20f144..c8f2a64 100644 --- a/src/query_builder.rs +++ b/src/query_builder.rs @@ -5,11 +5,72 @@ use std::any::Any; use std::collections::HashMap; use crate::drivers::{DatabaseDriver, DefaultDriver}; -use crate::enums::*; use crate::fns::split_map_join; use regex::Regex; +/// The position of the wildcard(s) +/// for a `like` clause +#[derive(Debug)] +pub enum LikeWildcard { + /// Wildcard before search term + /// eg. `%foo` + Before, + + /// Wildcard after the search term + /// eg. `foo%` + After, + + /// Wildcards surrounding the search term + /// eg. `%foo%` + Both, +} + +/// The type of SQL join +#[derive(Debug)] +pub enum JoinType { + /// A `CROSS` join + Cross, + /// An `INNER` join + Inner, + /// An `OUTER` join + Outer, + /// A `LEFT (OUTER)` join + Left, + /// A `RIGHT (OUTER)` join + Right, +} + +/// The sort direction +#[derive(Debug, PartialEq)] +pub enum OrderDirection { + /// Sort Ascending + Asc, + /// Sort Descending + Desc, + /// Random Sort (Not yet implemented!) + Rand, +} + +/// The type of Query Clause +#[derive(Debug, PartialEq)] +enum QueryClauseType { + /// Ending a parenthetical grouping + GroupEnd, + /// Starting a parenthetical grouping + GroupStart, + /// A having clause + Having, + /// A join clause + Join, + /// A like clause + Like, + /// A where clause + Where, + /// A where in clause + WhereIn, +} + #[derive(Debug)] enum QueryType { Select,