rbatis

Rust Compile Time ORM robustness,async, pure Rust Dynamic SQL

APACHE-2.0 License

Downloads
1.1M
Stars
2.3K
Committers
25

Bot releases are hidden (Show)

rbatis - v1.7.24

Published by zhuxiujia almost 4 years ago

v1.7.24

  • fix support futures for tokio02
rbatis - v1.7.23

Published by zhuxiujia about 4 years ago

v1.7.23

  • remove Tokio dep,only use async_std(Because it already supports Tokio02 and 03).
  • you can use async_std choose tokio02 runtime
async-std = { version = "1.6", features = ["attributes","tokio02"] }
rbatis - v1.7.21

Published by zhuxiujia about 4 years ago

v1.7.21

  • sqlite use MutexLock keep thread safe
rbatis - v1.7.2

Published by zhuxiujia about 4 years ago

v1.7.2

  • add Log plugin
  • add support disable/enable generated rust code print features for 'rbatis-macro-driver' toml.
rbatis - v1.7.1

Published by zhuxiujia about 4 years ago

v1.7.1

  • fix connection Pool init with min_size(old version is init max_size)
rbatis - v1.7.0

Published by zhuxiujia about 4 years ago

v1.7.0

  • use new of SyncMap(based on Tokio/AsyncStd's RWLock+std::HashMap)
    Older versions of dashmap block the runtime when a transaction starts,so we use new of SyncMap replace it!
    ‘SyncMap’ Ensure that when a transaction is running, simultaneous access to the transaction will only block the currently running coprocessor

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>>,
}
  • PagePlugin will be remove order by sql
rbatis - v1.6.39

Published by zhuxiujia about 4 years ago

v1.6.39

  • 'sql' and 'py_sql' macro support page plugin

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> {}
rbatis - v1.6.38

Published by zhuxiujia about 4 years ago

v1.6.38

  • recode proc macro for 'sql','py_sql' macro
  • rename method RB.execute_parperd() to RB.exec_prepare()
rbatis - v1.6.37

Published by zhuxiujia about 4 years ago

v1.6.37

  • support opt '-' in express engine

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


rbatis - v1.6.36

Published by zhuxiujia about 4 years ago

v1.6.36

  • fix py parser 's bug
  • express support for example: '-1 != -1'
rbatis - v1.6.35

Published by zhuxiujia about 4 years ago

v1.6.35

  • fix sql macro bug: not send 'tx_id'
rbatis - v1.6.34

Published by zhuxiujia about 4 years ago

v1.6.34

  • macro auto gen CRUDEnable table_name return raw string.improve performance
  • fix Manually implement CRUDEnable for table_columns() have whitespace bug。
rbatis - v1.6.32

Published by zhuxiujia about 4 years ago

v1.6.32

  • add Raw identifiers support in CRUDEnable macro for #38
rbatis - v1.6.31

Published by zhuxiujia about 4 years ago

v1.6.31

  • move sql '%' into arg for Wrapper. like(),not_like(),like_left(),like_right()
rbatis - v1.6.3

Published by zhuxiujia about 4 years ago

v1.6.3

  • fix #30 fix stmt sql for Wrapper.like() method
  • rewrite CRUDEnable trait, reduce needless method
  • remove check arg len in 'sql' macro
  • add ColumnFormat on CRUD update_by_wrapper,update_by_id
  • fix some bugs
rbatis - v1.6.2

Published by zhuxiujia about 4 years ago

v1.6.2

  • rbatis some method change arg type to Serialize trait(so you can send any Serialize value into this method)
  • driver add bind sql type for bool
  • add join test in crud_test.rs
  • py_sql macro support add 'tx_id' into method
rbatis - v1.6.0

Published by zhuxiujia about 4 years ago

v1.6.0

  • fix #31
rbatis - v1.5.9

Published by zhuxiujia about 4 years ago

v1.5.9

  • Fix #30 #31 #29 and add custom format for sql type (for Postgres example : {}::timestamp )
  • 修复了 Fix #30 #31 #29
  • 增加了实验性的ColumnFormat 接口,已适应在某些特殊类型的转换(例如自定义转换 Postgres {}::timestamp)
rbatis - v1.5.7

Published by zhuxiujia about 4 years ago

v1.5.7

  • 新增了宏生成py_sql的功能例如:
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"]
rbatis - v1.5.6

Published by zhuxiujia about 4 years ago

v1.5.6

  • 修复了Pg数据库Varchar数据映射的一些bug
  • 升级了BigDecimal库
  • 表达式引擎支持none关键字识别
  • 智能宏映射(新功能)同样较为方便
 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);
    }