Skip to content

Commit

Permalink
MySQL support
Browse files Browse the repository at this point in the history
  • Loading branch information
alu committed Oct 1, 2019
1 parent 2d61c1a commit e629ad8
Show file tree
Hide file tree
Showing 9 changed files with 948 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ geo = "0.4"
time = "0.1.14"
rustorm_dao = "0.4.0"
rustorm_codegen = "0.3.0"
r2d2_mysql = {version = "16.0.0", optional = true}



Expand All @@ -46,6 +47,7 @@ travis-ci = { repository = "ivanceras/rustorm" }
##default = ["with-postgres"]
with-postgres = ["postgres", "r2d2_postgres", "postgres-shared"]
with-sqlite = ["rusqlite","r2d2_sqlite"]
with-mysql = ["r2d2_mysql"]


[package.metadata.docs.rs]
Expand Down
2 changes: 2 additions & 0 deletions crates/dao/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ impl<'a> TryFrom<&'a Value> for NaiveDateTime {
fn try_from(value: &Value) -> Result<Self, Self::Error> {
match *value {
Value::Text(ref v) => Ok(parse_naive_date_time(v)),
Value::DateTime(v) => Ok(v),
_ => Err(ConvertError::NotSupported(
format!("{:?}", value),
"NaiveDateTime".to_string(),
Expand Down Expand Up @@ -310,6 +311,7 @@ impl<'a> TryFrom<&'a Value> for DateTime<Utc> {
fn try_from(value: &Value) -> Result<Self, Self::Error> {
match *value {
Value::Text(ref v) => Ok(DateTime::<Utc>::from_utc(parse_naive_date_time(v), Utc)),
Value::DateTime(v) => Ok(DateTime::<Utc>::from_utc(v, Utc)),
Value::Timestamp(v) => Ok(v),
_ => Err(ConvertError::NotSupported(
format!("{:?}", value),
Expand Down
13 changes: 13 additions & 0 deletions src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,16 @@ pub trait Database {
em: &EntityManager,
) -> Result<Option<DatabaseName>, DbError>;
}

pub trait Database2 {
fn execute_sql_with_return(
&mut self,
sql: &str,
param: &[&Value],
) -> Result<Rows, DbError>;

fn get_table(
&mut self,
table_name: &TableName,
) -> Result<Table, DbError>;
}

0 comments on commit e629ad8

Please sign in to comment.