-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can't use array as query parameters #47
Comments
You should read doc website https://rbatis.github.io/rbatis.io/#/README_EN?id=wrapper Here is how to use wrapper |
I think that I can't use wrapper because result data type is Vec:
|
try use macro,Use macros for cleaner and cleaner generation #[py_sql(rbatis, "select * from biz_activity where delete_flag = 0
AND id in
for item in ids:
#{item}")]
fn py_select_vec(rbatis:&Rbatis,ids: &Vec<String>) -> Vec<String> {
}
#[async_std::test]
pub async fn test_vec() {
fast_log::init_log("requests.log", 1000, log::Level::Info, true);
//use static ref
RB.link("mysql://root:123456@localhost:3306/test").await.unwrap();
let a = py_select_vec(&RB,&vec!["1".to_string(), "2".to_string()]).await.unwrap();
println!("{:?}", a);
}
and .... if you use fetch_prepare method RB.fetch_prepare(
"",
r#"
SELECT guid
FROM records
WHERE guid = ANY($1,$2,$3)
AND source_id = $2"#,
vec![json!(&guids[0]),json!(&guids[1]),json!(&guids[2]), json!(&1)]
) |
Finally, you can use fast_log to disable logs from SQLX。 use fast_log::fast_log::LogAppender;
use fast_log::plugin::file::FileAppender;
use fast_log::plugin::console::ConsoleAppender;
use fast_log::filter::ModuleFilter;
pub fn init_log() {
let mut appenders: Vec<Box<dyn LogAppender>> = vec![
Box::new(FileAppender::new("requests.log"))
];
if true {
appenders.push(Box::new(ConsoleAppender {}));
}
fast_log::init_custom_log(appenders, 1000, log::Level::Info, Box::new(
//NoFilter{}//not filter
//Module
ModuleFilter {
//contains
contains: None,
//exclude_contains
exclude_contains: Some(vec![
"sqlx".to_string()
]),
}
));
} |
So now I see that arrays as parameters not supported. |
array param not support in prepare method。 maybe we need add fetch_prepare_wrapper method。 |
Hi!
I can't find a way to use an array in queries. Here is an example:
Logs:
The text was updated successfully, but these errors were encountered: