Skip to content

Commit

Permalink
Merge pull request #24 from wslongchen/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
wslongchen authored Dec 27, 2021
2 parents 1083aea + ca55b3b commit af54ae3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "akita"
version = "0.3.6"
version = "0.3.7"
authors = ["mrpan <[email protected]>"]
edition = "2018"
description = "Akita - Mini orm for rust."
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Akita &emsp; [![Build Status]][actions] [![Latest Version]][crates.io] [![akita: rustc 1.13+]][Rust 1.13] [![akita_derive: rustc 1.31+]][Rust 1.31]

[Build Status]: https://img.shields.io/docsrs/akita/0.3.6?style=plastic
[Build Status]: https://img.shields.io/docsrs/akita/0.3.7?style=plastic
[actions]: https://github.com/wslongchen/akita/actions?query=branch%3Amaster
[Latest Version]: https://img.shields.io/crates/v/akita?style=plastic
[crates.io]: https://crates.io/crates/akita
Expand Down
20 changes: 17 additions & 3 deletions akita_core/src/param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ impl From<Vec<Value>> for Params {
}
}


impl <T: ToValue> From<T> for Params {
fn from(x: T) -> Params {
Params::Vector(vec![x.to_value()])
let v = x.to_value();
match v {
Value::Nil => Params::Nil,
_ => Params::Vector(vec![v.to_owned()]),
}

}
}

Expand Down Expand Up @@ -48,13 +54,21 @@ where

impl From<Value> for Params {
fn from(x: Value) -> Params {
Params::Vector(vec![x])
match x {
Value::Nil => Params::Nil,
_ => Params::Vector(vec![x]),
}
}
}

impl <'a> From<&'a dyn ToValue> for Params {
fn from(x: &'a dyn ToValue) -> Params {
Params::Vector(vec![x.to_value().to_owned()])

let v = x.to_value();
match v {
Value::Nil => Params::Nil,
_ => Params::Vector(vec![v.to_owned()]),
}
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ impl AkitaManager {
Ok(rows)
}

pub fn execute_drop<S: Into<String>, P: Into<Params>>(
&mut self,
sql: S,
params: P,
) -> Result<(), AkitaError> {
let rows = self.0.execute_drop(&sql.into(), params.into())?;
Ok(())
}

pub fn execute_iter<S: Into<String>, P: Into<Params>>(
&mut self,
sql: S,
Expand Down Expand Up @@ -922,8 +931,7 @@ impl AkitaMapper for AkitaEntityManager{
) -> Result<(), AkitaError>
{
let sql: String = sql.into();
let _result: Result<Vec<()>, AkitaError> = self.execute_result(&sql, params);
Ok(())
self.0.execute_drop(&sql, params.into())
}

fn execute_result_opt<'a, R, S: Into<String>, P: Into<Params>>(
Expand Down
4 changes: 2 additions & 2 deletions tests/akita.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::time::Duration;
use akita::*;
use chrono::NaiveDateTime;

#[derive(AkitaTable, Clone, Default, ToValue, FromValue)]
#[derive(AkitaTable, Clone, Default)]
#[table(name = "t_system_user")]
pub struct User {
#[table_id(name = "id")]
Expand All @@ -20,7 +20,7 @@ pub struct User {
pub birthday: Option<NaiveDate>,
/// 性别
pub gender: u8,
#[field(exist = "false")]
#[field(exist = false)]
pub is_org: bool,
#[field(name = "token")]
pub url_token: String,
Expand Down

0 comments on commit af54ae3

Please sign in to comment.