Macro rbatis::pysql

source ·
macro_rules! pysql {
    ($fn_name:ident($($param_key:ident:$param_type:ty$(,)?)*) -> $return_type:ty => $py_file:expr) => { ... };
}
Expand description

use macro wrapper #[py_sql] for query example:

use rbatis::executor::Executor;
rbatis::pysql!(test_same_id(rb: &dyn Executor, id: &u64)  -> Result<rbs::Value, rbatis::Error> =>
"select * from table where ${id} = 1
 if id != 0:
   `id = #{id}`"
);

for exec example:

use rbatis::executor::Executor;
use rbdc::db::ExecResult;
rbatis::pysql!(test_same_id(rb: &dyn Executor, id: &u64)  -> Result<ExecResult, rbatis::Error> =>
"`update activity set name = '1' where id = #{id}`"
);