-
Notifications
You must be signed in to change notification settings - Fork 157
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
Transactton Token error: 'Incorrect syntax near 'begin'.' on server #473
Comments
SQL Server 2016 supports starting a transaction using I suggest you use an interceptor to modify the transaction statement start to #[derive(Debug)]
pub struct TxIntercept {}
#[async_trait]
impl Intercept for TxIntercept {
async fn before(
&self,
_task_id: i64,
_rb: &dyn Executor,
sql: &mut String,
_args: &mut Vec<Value>,
_result: ResultType<&mut Result<ExecResult, Error>, &mut Result<Vec<Value>, Error>>,
) -> Result<bool, Error> {
if sql.contains("begin") {
*sql = sql.replace("begin","BEGIN TRANSACTION").to_string();
} else if sql.contains("commit") {
*sql = sql.replace("commit","COMMIT TRANSACTION").to_string();
} else if sql.contains("rollback") {
*sql = sql.replace("rollback","ROLLBACK TRANSACTION").to_string();
}
Ok(true)
}
}
#[tokio::main]
pub async fn main() {
fast_log::init(fast_log::Config::new().console()).expect("rbatis init fail");
defer!(|| log::logger().flush());
let rb = RBatis::new();
rb.intercepts.push(Arc::new(TxIntercept {}));
} |
Thank you very much that the interceptor has taken effect. |
did you call commit method or rollback ? |
#488 Already solved |
database:sql server 2016.
Sql server does not support 'begin'.
Please give me some advice?
The text was updated successfully, but these errors were encountered: