Rbatis Versions Save

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

v4.5.12

4 months ago

v4.5.12

  • fix tx use intercept
  • add TxIntercept

v4.5.11

4 months ago

what changes?

  • Require rust compiler 1.75,maybe you need run rustup update
  • LogInterceptor remove replace_holder

v4.5.10

5 months ago

what changes?

  • deprecated sql mod
  • page,tx move to plugin
  • Require rust compiler 1.75,maybe you need run rustup update

v4.5.7

5 months ago

v4.5.7

what changes?

  • add new crates fast_pool
  • add new crates rbdc-pool-fast based on fast_pool
  • Pool Performance improvement
  • Require rust compiler 1.75,maybe you need run rustup update
// bench method pool.get().await.unwrap()
//windows:
//---- bench_pool stdout ----
//use Time: 4.0313ms ,each:40 ns/op
//use QPS: 24749412 QPS/s
//macos:
//---- bench_pool stdout ----
// use Time: 6.373708ms ,each:63 ns/op
// use QPS: 15683710 QPS/s

v4.5.6

6 months ago

v4.5.6

  • move IntoSql trait to rbatis-codegen
  • rbatis-codegen fix many bug
  • rbatis-codegen add impl_numeric_bitand! { op_bit_and_u64[u8 u16 u32 u64] -> u64 op_bit_and_i64[i8 i16 i32 i64 isize] -> i64 } and impl_numeric_bitor! { op_bit_or_u64[u8 u16 u32 u64] -> u64 op_bit_or_i64[i8 i16 i32 i64 isize] -> i64 }
  • add many test for html-sql just like
<select id="test_binary">
 `${id + 1},${id - 1},${id * 1},${id / 1},${id % 1},${id & 1},${id | 1},${id == 1},${id < 1},${id <= 1},${id != 1},${id >= 1},${id > 1},${id ^ 1},${b && true},${b || true}`
</select>

v4.5.5

6 months ago

v4.5.5

  • add DefaultPool pub use rbdc_pool_mobc::MobcPool as DefaultPool;

v4.5.4

6 months ago

v4.5.4

  • add sync method for rbatis create table if not exists, add column if not exists

    use rbatis::RBatis;
    use rbatis::table_sync::{SqliteTableMapper};
    
     let rb = RBatis::new();
     let conn = rb.acquire().await;
    pub async fn do_sync_table(rb: &RBatis){
          let map = rbs::to_value!{
                "id":"INT",
                "name":"TEXT",
         };
         let _ = RBatis::sync(&rb,&SqliteTableMapper{},&map,"user").await;
    }
    
    use rbatis::RBatis;
    use rbatis::table_sync::{SqliteTableMapper};
    
    #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
    pub struct User{
      pub id:String,
      pub name: Option<String>
    }
    
     let rb = RBatis::new();
     let conn = rb.acquire().await;
    pub async fn do_sync_table(rb: &RBatis){
         let table = User{id: "".to_string(), name: Some("".to_string())};
         let _ = RBatis::sync(&rb,&SqliteTableMapper{},&table,"user").await;
    }
    
    use rbatis::RBatis;
    use rbatis::table_sync::{MysqlTableMapper};
    
    #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
    pub struct User{
      pub id:String,
      pub name: Option<String>
    }
    
     let rb = RBatis::new();
     let conn = rb.acquire().await;
    pub async fn do_sync_table_mysql(rb: &RBatis){
         let table = User{id: "".to_string(), name: Some("VARCHAR(50)".to_string())};
         let _ = RBatis::sync(&rb,&MysqlTableMapper{},&table,"user").await;
    }
    

v4.5.3

6 months ago

v4.5.3

  • fix for #463

v4.5.2

6 months ago

v4.5.2

  • rbatis remove rbdc fetaures
  • only driver need add features = ["tls-rustls"] or features = ["tls-native-tls"]

just like example

rbs = { version = "4.5" }
rbdc-sqlite = { version = "4.5", default-features = false, features = ["tls-native-tls"] }
#rbdc-mysql={version="4.5", default-features = false, features = ["tls-native-tls"]}
#rbdc-pg={version="4.5", default-features = false, features = ["tls-native-tls"]}
#rbdc-mssql={version="4.5", default-features = false, features = ["tls-native-tls"]}
rbatis = { version = "4.5"}
#other deps
serde = { version = "1", features = ["derive"] }
tokio = { version = "1", features = ["full"] }
log = "0.4"
fast_log = "1.6"

v4.5.1

6 months ago
  • add Pool Trait, you can design your any Pool! for example:
#[derive(Debug)]
pub struct MobcPool {
    pub manager:ConnManager,
    pub inner: mobc::Pool<ConnManager>,
}

unsafe impl Sync for MobcPool {}
unsafe impl Send for MobcPool {}

#[async_trait]
impl Pool for MobcPool {
    fn new(manager: ConnManager) -> Result<Self,Error> where Self: Sized {
        Ok(Self {
            manager:manager.clone(),
            inner: mobc::Pool::new(manager)
        })
    }

    async fn get(&self) -> Result<Box<dyn Connection>, Error> {
        let v = self.inner.get().await.map_err(|e|Error::from(e.to_string()))?;
        Ok(Box::new(v))
    }

    async fn get_timeout(&self, d: Duration) -> Result<Box<dyn Connection>, Error> {
        let v = self.inner.get_timeout(d).await.map_err(|e|Error::from(e.to_string()))?;
        Ok(Box::new(v))
    }

    async fn set_conn_max_lifetime(&self, max_lifetime: Option<Duration>) {
       self.inner.set_conn_max_lifetime(max_lifetime).await;
    }

    async fn set_max_idle_conns(&self, n: u64) {
        self.inner.set_max_idle_conns(n).await;
    }

    async fn set_max_open_conns(&self, n: u64) {
        self.inner.set_max_open_conns(n).await;
    }

    fn driver_type(&self) -> &str {
        self.manager.driver_type()
    }

}

#[async_trait]
impl mobc::Manager for ConnManager {
    type Connection = ConnectionBox;
    type Error = Error;

    async fn connect(&self) -> Result<Self::Connection, Self::Error> {
        self.connect().await
    }

    async fn check(&self, conn: Self::Connection) -> Result<Self::Connection, Self::Error> {
        self.check( conn).await
    }
}


impl Connection for mobc::Connection<ConnManager>{
    fn get_rows(&mut self, sql: &str, params: Vec<Value>) -> BoxFuture<Result<Vec<Box<dyn Row>>, Error>> {
        self.conn.as_mut().unwrap().get_rows(sql,params)
    }

    fn exec(&mut self, sql: &str, params: Vec<Value>) -> BoxFuture<Result<ExecResult, Error>> {
        self.conn.as_mut().unwrap().exec(sql,params)
    }

    fn ping(&mut self) -> BoxFuture<Result<(), Error>> {
        self.conn.as_mut().unwrap().ping()
    }

    fn close(&mut self) -> BoxFuture<Result<(), Error>> {
        self.conn.as_mut().unwrap().close()
    }
}


  • use MobcPool
   use rbatis::RBatis;
    use rbdc::pool::pool_mobc::MobcPool;
    use rbdc_sqlite::{SqliteConnectOptions, SqliteDriver};
    let rb=RBatis::new();
   
    let opts=SqliteConnectOptions::new();
    let rbatis = rb.init_option::<SqliteDriver, SqliteConnectOptions, MobcPool>(SqliteDriver{},opts);