From 9e4b483b2b0d535bada30f0e64fce0e736a512da Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 16 Apr 2019 16:26:55 -0400 Subject: [PATCH] Prepwork for the type apocalypse --- src/main.rs | 20 -------------------- src/query_builder.rs | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 20 deletions(-) delete mode 100644 src/main.rs diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index 7a81a54..0000000 --- a/src/main.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! This main file is just for temparary testing -use stringqb::prelude::*; - -fn main() { - let mut qb = QueryBuilder::new(PostgresDriver::new()); - - qb.set("foo", Box::new("bar")) - .set("bar", Box::new(12)) - .set("baz", Box::new(false)) - .set("fizz", Box::new(12.38)) - .set("buzz", Box::new((1, 2.0, true, 'q'))); - - // This just makes me sad - qb.r#where("foo <>", Box::new(2)); - - println!("QueryBuilder object: {:#?}", &qb); - - // println!("SQLType mapping: {:#?}", SQLType::SmallInt(32)); - // println!("Type: {:#?}", Type(Box::new(1234567890))); -} diff --git a/src/query_builder.rs b/src/query_builder.rs index 64e52a2..1a5bd1c 100644 --- a/src/query_builder.rs +++ b/src/query_builder.rs @@ -190,6 +190,16 @@ impl QueryBuilder { // -------------------------------------------------------------------------- /// Add a `having` clause to the query + /// + /// ```no_run + /// # use stringqb::prelude::*; + /// # let mut qb = QueryBuilder::default(); + /// // By default, key = value + /// qb.having("key", vec![Box::new("value")]); + /// + /// // Other operators can be used with a separating space + /// qb.having("clues >=", vec![Box::new(4)]); + /// ``` pub fn having(&mut self, key: &str, value: Vec>) -> &mut Self { self._having(key, value, "AND") } @@ -483,6 +493,11 @@ impl QueryBuilder { self } + /// Execute an SQL query + pub fn query(&mut self, sql: &str) { + unimplemented!(); + } + // -------------------------------------------------------------------------- // ! Implementation Details // --------------------------------------------------------------------------