Rust Compile Time ORM robustness,async, pure Rust Dynamic SQL
APACHE-2.0 License
Published by zhuxiujia almost 4 years ago
v1.7.24
Published by zhuxiujia about 4 years ago
v1.7.23
async-std = { version = "1.6", features = ["attributes","tokio02"] }
Published by zhuxiujia about 4 years ago
v1.7.21
Published by zhuxiujia about 4 years ago
v1.7.2
Published by zhuxiujia about 4 years ago
v1.7.1
Published by zhuxiujia about 4 years ago
v1.7.0
this is impl rust code detail
#[cfg(feature = "runtime-async-std")]
pub(crate) use async_std::{
sync::RwLock,
sync::RwLockReadGuard,
sync::RwLockWriteGuard
};
#[cfg(feature = "runtime-tokio")]
pub(crate) use tokio::{
sync::RwLock,
sync::RwLockReadGuard,
sync::RwLockWriteGuard
};
use crate::runtime::{RwLock, RwLockReadGuard, RwLockWriteGuard};
pub struct SyncMap<K, V> where K: Eq + Hash {
pub shard: RwLock<HashMap<K, V, RandomState>>,
}
Published by zhuxiujia about 4 years ago
v1.6.39
for example:
//sql macro
#[sql(RB, "select * from biz_activity where delete_flag = 0 and name = ?")]
fn sql_select_page(page_req: &PageRequest, name: &str) -> Page<BizActivity> {}
// py_sql macro
#[py_sql(RB, "select * from biz_activity where delete_flag = 0
if name != '':
and name=#{name}")]
fn py_select_page(page_req: &PageRequest, name: &str) -> Page<BizActivity> {}
Published by zhuxiujia about 4 years ago
v1.6.38
Published by zhuxiujia about 4 years ago
v1.6.37
for example(node_test.rs):
d.a == null
express: d.a == null >>>>> true
'2019-02-26' == '2019-02-26'
express: '2019-02-26' == '2019-02-26' >>>>> true
`f`+`s`
express: `f`+`s` >>>>> "fs"
a +1 > b * 8
express: a +1 > b * 8 >>>>> false
a >= 0
express: a >= 0 >>>>> true
'a'+c
express: 'a'+c >>>>> "ac"
b
express: b >>>>> 2
a < 1
express: a < 1 >>>>> false
a +1 > b*8
express: a +1 > b*8 >>>>> false
a * b == 2
express: a * b == 2 >>>>> true
a - b == 0
express: a - b == 0 >>>>> false
a >= 0 && a != 0
express: a >= 0 && a != 0 >>>>> true
a == 1 && a != 0
express: a == 1 && a != 0 >>>>> true
1 > 3
express: 1 > 3 >>>>> false
1 + 2 != nil
express: 1 + 2 != nil >>>>> true
1 != null
express: 1 != null >>>>> true
1 + 2 != nil && 1 > 0
express: 1 + 2 != nil && 1 > 0 >>>>> true
1 + 2 != nil && 2 < b*8
express: 1 + 2 != nil && 2 < b*8 >>>>> true
-1 != nil
express: -1 != nil >>>>> true
-1 != -2 && -1 == 2-3
express: -1 != -2 && -1 == 2-3 >>>>> true
-1 == a*-1
express: -1 == a*-1 >>>>> true
-1 + a*-1
express: -1 + a*-1 >>>>> -2.0
Published by zhuxiujia about 4 years ago
v1.6.36
Published by zhuxiujia about 4 years ago
v1.6.35
Published by zhuxiujia about 4 years ago
v1.6.34
Published by zhuxiujia about 4 years ago
v1.6.32
Published by zhuxiujia about 4 years ago
v1.6.31
Published by zhuxiujia about 4 years ago
v1.6.3
Published by zhuxiujia about 4 years ago
v1.6.2
Published by zhuxiujia about 4 years ago
v1.6.0
Published by zhuxiujia about 4 years ago
v1.5.9
Published by zhuxiujia about 4 years ago
v1.5.7
lazy_static! {
static ref RB:Rbatis=Rbatis::new();
}
#[py_sql(RB, "select * from biz_activity where id = #{name}
if name != '':
and name=#{name}")]
fn py_select(name: &str) -> Option<BizActivity> {}
#[async_std::test]
pub async fn test_macro_py_select() {
fast_log::log::init_log("requests.log", &RuntimeType::Std);
RB.link("mysql://root:123456@localhost:3306/test").await.unwrap();
let a = py_select("1").await.unwrap();
println!("{:?}", a);
}
INFO rbatis::rbatis - [rbatis] [] Query ==> select * from biz_activity where id = ? and name= ?
INFO rbatis::rbatis - [rbatis] [] Args ==> ["1","1"]
Published by zhuxiujia about 4 years ago
v1.5.6
lazy_static! {
static ref RB:Rbatis=Rbatis::new();
}
/// 宏根据方法定义生成执行逻辑,又点类似于 java/mybatis的@select动态sql
/// RB是本地依赖Rbatis引用的名称,例如 dao::RB, com::xxx::RB....都可以
/// 第二个参数是标准的驱动sql,注意对应数据库参数mysql为?,pg为$1...
/// 宏会自动转换函数为 pub async fn select(name: &str) -> rbatis_core::Result<BizActivity> {}
///
#[sql(RB, "select * from biz_activity where id = ?")]
fn select(name: &str) -> BizActivity {}
//其他写法: pub async fn select(name: &str) -> rbatis_core::Result<BizActivity> {}
#[async_std::test]
pub async fn test_macro() {
fast_log::log::init_log("requests.log", &RuntimeType::Std);
RB.link("mysql://root:123456@localhost:3306/test").await.unwrap();
let a = select("1").await.unwrap();
println!("{:?}", a);
}