#[py_sql]
Expand description
py sql create macro,this macro use RB.py_query and RB.py_exec
use rbatis::executor::Executor;
use rbatis::py_sql;
#[derive(serde::Serialize,serde::Deserialize)]
pub struct MockTable{}
#[py_sql("select * from biz_activity where delete_flag = 0")]
async fn py_select_page(rb: &dyn Executor, name: &str) -> Vec<MockTable> { }
or more example:
use rbatis::executor::Executor;
use rbatis::py_sql;
#[derive(serde::Serialize,serde::Deserialize)]
pub struct MockTable{}
#[py_sql("
SELECT * FROM biz_activity
if name != null:
AND delete_flag = #{del}
AND version = 1
if age!=1:
AND version = 1
AND version = 1
AND a = 0
AND version = 1
and id in (
trim ',': for item in ids:
#{item},
)
and id in (
trim ',': for index,item in ids:
#{item},
)
trim 'AND':
AND delete_flag = #{del2}
choose:
when age==27:
AND age = 27
otherwise:
AND age = 0
WHERE id = '2'")]
pub async fn py_select_rb(rb: &dyn Executor, name: &str) -> Option<MockTable> {}
or read from file
//#[rbatis::py_sql(r#"include!("C:/rs/rbatis/target/debug/xx.py_sql")"#)]
//pub async fn test_same_id(rb: &dyn Executor, id: &u64) -> Result<Value, Error> { impled!() }