Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mssql): avoid calling
.commit()
unless a DDL operation is being…
… performed (#9658) This PR attempts to address flaky behavior of MS SQL observed in CI. It seems like calling `commit()`/`rollback()` with a `SELECT` statement, AKA autocommit behavior can cause this issue. The origin is not 100% clear to me, but there are a number of places where the same problem (function sequence error) with the same solution show up (disabling autocommit or not calling commit with a `SELECT` statement): - https://stackoverflow.com/questions/25769043/function-sequence-error-in-pyodbc - ansible-collections/community.general#1137 - https://www.reddit.com/r/learnpython/comments/x8568m/function_sequence_error_in_sqlalchemy/ - explorerhq/sql-explorer#423 Here I avoid calling `cur.commit()` unless a DDL statement is being executed. The remaining case is `raw_sql()`, which I opted to avoid calling `commit` in since that would have this problem when calling it with a `SELECT` statement. Users of `raw_sql` are therefore responsible for handling commit/rollback when invoking it for DDL statements. Closes #9654.
- Loading branch information