Rust Compile Time ORM robustness,async, pure Rust Dynamic SQL
APACHE-2.0 License
Bot releases are hidden (Show)
what changes?
py_sql
Published by zhuxiujia 4 months ago
what changes?
Published by zhuxiujia 4 months ago
Published by zhuxiujia 5 months ago
what changes?
table_util.rs
macro ( you can use macro get like HashMap<String,&Table>
or HashMap<String,Table>
)use rbatis::rbdc::DateTime;
use rbatis::{table, table_field_btree, table_field_map, table_field_vec};
#[derive(serde::Serialize, serde::Deserialize,Default,Debug,Clone)]
pub struct Activity {
pub id: Option<i64>,
pub name: Option<String>,
pub pc_link: Option<String>,
pub h5_link: Option<String>,
pub pc_banner_img: Option<String>,
pub h5_banner_img: Option<String>,
pub sort: Option<String>,
pub status: Option<i32>,
pub remark: Option<String>,
pub create_time: Option<DateTime>,
pub version: Option<i64>,
pub delete_flag: Option<i32>,
}
fn main() {
let tables: Vec<Activity> = vec![
table!(Activity {
id: Some(3),
name: Some("3".to_string()),
}),
table!(Activity {
id: Some(2),
name: Some("2".to_string()),
}),
table!(Activity {
id: Some(1),
name: Some("1".to_string()),
})];
//map ref
let hash = table_field_map!(&tables,id);
println!("---hash={}", rbs::to_value!(hash));
//map owned
let hash_owned = table_field_map!(tables.clone(),id);
println!("---hash={}", rbs::to_value!(hash_owned));
//btree ref
let btree = table_field_btree!(&tables,id);
println!("---btree={}", rbs::to_value!(btree));
//btree owned
let btree_owned = table_field_btree!(tables.clone(),id);
println!("---btree_owned={}", rbs::to_value!(btree_owned));
//vec<ref>
let ids= table_field_vec!(&tables,id);
println!("---ids={}", rbs::to_value!(ids));
//vec<owned>
let ids= table_field_vec!(tables,id);
println!("---ids owned={:?}", ids);
}
Published by zhuxiujia 6 months ago
what changes?
Intercept
set return type -> Result<bool, Error>
to -> Result<Option<bool>, Error>
/// if return None will be return result
/// if return Some(true) will be run next intercept
/// if return Some(false) will be break
Published by zhuxiujia 7 months ago
what changes?
html_sql
,py_sql
support break
nodeupdate_by_column_skip
, update_by_column_batch_skip
for #501html_sql
,py_sql
the bind
node will set value to arg.rbs
ValueMap use index_map
cratePublished by zhuxiujia 7 months ago
what changes?
RBatisConnExecutor
rb_task_id use new_snowflake_id()
Published by zhuxiujia 7 months ago
what Changes?
"invalid type: integer `1`, expected a string, key=`status`"
)#toml
rbatis = { version = "4.5", features = ["debug_mode"]}
/// table
#[derive(serde::Serialize, serde::Deserialize)]
pub struct Activity {
pub status: Option<String>,
}
//log
[INFO] [rbatis] [608325834525440517] query <= len=1,rows=[{"status":1}]
called `Result::unwrap()` on an `Err` value: E("invalid type: integer `1`, expected a string, key = `status`")
stack backtrace:
0: std::panicking::begin_panic_handler
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\panicking.rs:645
1: core::panicking::panic_fmt
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\core\src\panicking.rs:72
Published by zhuxiujia 8 months ago
what change?
Published by zhuxiujia 8 months ago
what changes?
Published by zhuxiujia 8 months ago
what changes?
now you can use
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Account {
pub id: Option<u64>,
pub name: Option<String>,
}
#[derive(Clone, serde::Serialize, serde::Deserialize)]
pub struct User {
pub id: Option<u64>,
//json support json object/array/null
pub account1: Account,
//json support json object/array/null
pub account2: Vec<Account>,
}
async fn create_table(rb: &RBatis) {
fast_log::LOGGER.set_level(LevelFilter::Off);
defer!(||{
fast_log::LOGGER.set_level(LevelFilter::Info);
});
// let table = User {
// id: Some(1),
// account1: Account {
// id: Some(1),
// name: Some("".to_string()),
// },
// account2: vec![Account {
// id: Some(1),
// name: Some("".to_string()),
// }],
// };
let table = to_value!{
"id":"INTEGER PRIMARY KEY AUTOINCREMENT",
"account1":"JSON",
"account2":"JSON",
};
let conn = rb.acquire().await.unwrap();
_ = table_sync::sync(&conn, &SqliteTableMapper {}, to_value!(&table), "user").await.unwrap();
}
Published by zhuxiujia 8 months ago
what changes?
impl_select_page
macro issue of failed compilation of ownership parametersPublished by zhuxiujia 8 months ago
what changes?
crud
macro Generate the 'snake-case' table name on compile-timePublished by zhuxiujia 9 months ago
what changes?
Connection
trait add some translation methodsConnection
trait translation methodsPublished by zhuxiujia 9 months ago
v4.5.12
Published by zhuxiujia 9 months ago
what changes?
Published by zhuxiujia 10 months ago
what changes?
rustup update
Published by zhuxiujia 10 months ago
v4.5.7
rbdc-pool-fast
based on fast_pool
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
Published by zhuxiujia 11 months ago
v4.5.6
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 }
<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>
Published by zhuxiujia 11 months ago
v4.5.5
pub use rbdc_pool_mobc::MobcPool as DefaultPool;