From 834cd358b6c122d63e054c2aefc46b94f63c9730 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 23 Apr 2019 09:58:03 -0400 Subject: [PATCH] Another progress commit --- src/drivers.rs | 4 ++++ src/drivers/mssql.rs | 4 ++++ src/drivers/mysql.rs | 4 ++++ src/drivers/sqlite.rs | 17 +++++++++++++++-- src/types.rs | 20 ++++++++++++++------ 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/src/drivers.rs b/src/drivers.rs index 3271267..08aeb43 100644 --- a/src/drivers.rs +++ b/src/drivers.rs @@ -39,6 +39,10 @@ impl DefaultDriver { } impl DatabaseDriver for DefaultDriver { +// fn query(&self, sql: &str) -> Result<(), ()> { +// Ok(()) +// } + fn explain(&self, sql: &str) -> String { format!("EXPLAIN {}", sql) } diff --git a/src/drivers/mssql.rs b/src/drivers/mssql.rs index d4e91e5..1592c53 100644 --- a/src/drivers/mssql.rs +++ b/src/drivers/mssql.rs @@ -24,6 +24,10 @@ impl DatabaseDriver for MSSQL { ('[', ']') } +// fn query(&self, sql: &str) -> Result<(), ()> { +// unimplemented!(); +// } + fn explain(&self, sql: &str) -> String { sql.to_string() } diff --git a/src/drivers/mysql.rs b/src/drivers/mysql.rs index 70bbe27..e46ad36 100644 --- a/src/drivers/mysql.rs +++ b/src/drivers/mysql.rs @@ -23,6 +23,10 @@ impl DatabaseDriver for MySQLDriver { ('`', '`') } +// fn query(&self, sql: &str) -> Result<(), ()> { +// unimplemented!(); +// } + fn limit(&self, sql: &str, limit: Option, offset: Option) -> String { if limit.is_none() { return sql.to_string(); diff --git a/src/drivers/sqlite.rs b/src/drivers/sqlite.rs index b7cf610..68e1895 100644 --- a/src/drivers/sqlite.rs +++ b/src/drivers/sqlite.rs @@ -1,20 +1,33 @@ //! Database Driver for SQLite //! +//! Use of this driver requires enabling the `sqlite` feature. +//! //! Contains database-specific query data use super::*; +use slite::{Connection}; +use std::cell::RefCell; + /// The struct implementing the `DatabaseDriver` trait #[derive(Debug)] -pub struct SQLiteDriver; +pub struct SQLiteDriver { + connection: RefCell> +} impl SQLiteDriver { /// Create an SQLiteDriver driver pub fn new() -> Self { - SQLiteDriver {} + SQLiteDriver { + connection: RefCell::new(None) + } } } impl DatabaseDriver for SQLiteDriver { +// fn query(&self, sql: &str) -> Result<(), ()> { +// unimplemented!(); +// } + fn explain(&self, sql: &str) -> String { format!("EXPLAIN QUERY PLAN {}", sql) } diff --git a/src/types.rs b/src/types.rs index 00e2b36..f6d0338 100644 --- a/src/types.rs +++ b/src/types.rs @@ -6,12 +6,20 @@ struct Type(pub Box); /// Enum struct for mapping between database and Rust types #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] -enum SQLType { - Boolean(T), - SmallInt(T), - BigInt(T), - Text(T), - None, +struct SQLType { + value: Option, +} + +fn is_str(s: &(dyn Any)) { + s.is::<&str>() +} + +fn is_string(s: &(dyn Any)) { + s.is::() +} + +fn is_bool(v: &(dyn Any)) { + v.is::() } impl SQLType {