Rust Compile Time ORM robustness,async, pure Rust Dynamic SQL
APACHE-2.0 License
Bot releases are visible (Hide)
Published by zhuxiujia almost 3 years ago
v3.0.13
fix rbatis::Bytes
decode(sqlite)
Published by zhuxiujia almost 3 years ago
v3.0.11
Published by zhuxiujia almost 3 years ago
v3.0.9
Published by zhuxiujia almost 3 years ago
v3.0.8
format_bson
to show some bson binary dataPublished by zhuxiujia almost 3 years ago
v3.0.7
Published by zhuxiujia almost 3 years ago
v3.0.5
Published by zhuxiujia almost 3 years ago
v3.0.4
Published by zhuxiujia almost 3 years ago
v3.0.2
value.cast_string() , value.cast_i64() value.cast_f64()
impl_field_name_method
and field_name
///We can use rbatis built-in macros to improve maintainability
#[cfg(test)]
mod test {
use rbatis::DriverType;
use rbatis::wrapper::Wrapper;
#[crud_table]
#[derive(Clone, Debug)]
pub struct BizActivity {
pub id: Option<String>,
pub name: Option<String>,
pub delete_flag: Option<i32>,
}
// this macro will create impl BizActivity{ pub fn id()->&str ..... }
impl_field_name_method!(BizActivity{id,name,delete_flag});
#[test]
fn test_improve_maintainability() {
// When name is changed to user_name, the code becomes unmaintainable,
// compiling well but with logic errors
let w = Wrapper::new(&DriverType::Mysql)
.eq("id","1")
.eq("name", "xiao ming")
.eq("delete_flag",1);
assert_eq!(w.sql,"id = ? and name = ? and delete_flag = ?");
// so we change "name" to column_name!(BizActivity::name),
// when field name change to user_name ,it will be Compilation fails
let w = Wrapper::new(&DriverType::Mysql)
.eq(field_name!(BizActivity.id),"1")
.eq(field_name!(BizActivity.name), "xiao ming")
.eq(field_name!(BizActivity.delete_flag),1);
assert_eq!(w.sql,"id = ? and name = ? and delete_flag = ?");
let w = Wrapper::new(&DriverType::Mysql)
.eq(BizActivity::id(),"1")
.eq(BizActivity::name(), "xiao ming")
.eq(BizActivity::delete_flag(),1);
assert_eq!(w.sql,"id = ? and name = ? and delete_flag = ?");
}
}
Published by zhuxiujia almost 3 years ago
v3.0.1
Published by zhuxiujia almost 3 years ago
v3.0.0
#choose rbatis runtime(default is ["all-database","runtime-async-std-rustls"])
runtime-tokio-rustls = ["rbatis-core/runtime-tokio-rustls"]
runtime-actix-rustls = ["rbatis-core/runtime-actix-rustls"]
runtime-async-std-rustls = ["rbatis-core/runtime-async-std-rustls"]
runtime-tokio-native-tls = ["rbatis-core/runtime-tokio-native-tls"]
runtime-actix-native-tls = ["rbatis-core/runtime-actix-native-tls"]
runtime-async-std-native-tls = ["rbatis-core/runtime-async-std-native-tls"]
Some types support deserialization of multiple types (for example, rbatis::DateNative can be deserialized by bson String or Bson Bytes)
data structure | is supported |
---|---|
Option | √ |
Vec | √ |
HashMap | √ |
i32,i64,f32,f64,bool,String...more rust type | √ |
rbatis::Bytes | √ |
rbatis::DateNative | √ |
rbatis::DateUtc | √ |
rbatis::DateTimeNative | √ |
rbatis::DateTimeUtc | √ |
rbatis::Decimal | √ |
rbatis::Json | √ |
rbatis::TimeNative | √ |
rbatis::TimeUtc | √ |
rbatis::Timestamp | √ |
rbatis::TimestampZ | √ |
rbatis::Uuid | √ |
rbatis::plugin::page::{Page, PageRequest} | √ |
bson::* | √ |
serde_json::* | √ |
any serde type | √ |
Published by zhuxiujia almost 3 years ago
v2.1.9
Published by zhuxiujia almost 3 years ago
v2.1.8
Published by zhuxiujia almost 3 years ago
v2.1.7
let v: RbJson = serde_json::from_str("{\"rb_json\":1}").unwrap();
println!("{:?}", v);
let v: RbJson = serde_json::from_str("{\"ds\":1}").unwrap();
println!("{:?}", v);
let v: RbJson = serde_json::from_str("1").unwrap();
println!("{:?}", v);
let v: RbJson = serde_json::from_str("\"string\"").unwrap();
println!("{:?}", v);
let v: RbJson = serde_json::from_str("true").unwrap();
println!("{:?}", v);
Published by zhuxiujia almost 3 years ago
v2.1.5
RbatisExecutor<'_>
lifetime to RbatisExecutor<'_,'_>
Published by zhuxiujia about 3 years ago
v2.1.4
Published by zhuxiujia about 3 years ago
v2.1.3
Published by zhuxiujia about 3 years ago
v2.1.2
use rbatis::core::types::byte::RbBytes;
use rbatis::core::types::json::RbJson;
#[crud_table]
#[derive(Clone, Debug)]
pub struct Table {
pub bytes: Option<RbBytes>,
pub json: Option<RbJson>,
}
&rb.new_wrapper()
to rb.new_wrapper()
Published by zhuxiujia about 3 years ago
v2.0.30
where
nodePublished by zhuxiujia about 3 years ago
v2.0.29
Published by zhuxiujia about 3 years ago
v2.0.28
and
or
keyword