Another progress commit

This commit is contained in:
Timothy Warren 2019-04-23 09:58:03 -04:00
parent 861069abe7
commit 834cd358b6
5 changed files with 41 additions and 8 deletions

View File

@ -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)
}

View File

@ -24,6 +24,10 @@ impl DatabaseDriver for MSSQL {
('[', ']')
}
// fn query(&self, sql: &str) -> Result<(), ()> {
// unimplemented!();
// }
fn explain(&self, sql: &str) -> String {
sql.to_string()
}

View File

@ -23,6 +23,10 @@ impl DatabaseDriver for MySQLDriver {
('`', '`')
}
// fn query(&self, sql: &str) -> Result<(), ()> {
// unimplemented!();
// }
fn limit(&self, sql: &str, limit: Option<usize>, offset: Option<usize>) -> String {
if limit.is_none() {
return sql.to_string();

View File

@ -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<Option<Connection>>
}
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)
}

View File

@ -6,12 +6,20 @@ struct Type(pub Box<dyn Any>);
/// Enum struct for mapping between database and Rust types
#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
enum SQLType<T> {
Boolean(T),
SmallInt(T),
BigInt(T),
Text(T),
None,
struct SQLType<T> {
value: Option<T>,
}
fn is_str(s: &(dyn Any)) {
s.is::<&str>()
}
fn is_string(s: &(dyn Any)) {
s.is::<String>()
}
fn is_bool(v: &(dyn Any)) {
v.is::<bool>()
}
impl<T> SQLType<T> {