Skip to content
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

Support default transaction mode. #426

Conversation

masamitsu-murase
Copy link
Contributor

@masamitsu-murase masamitsu-murase commented Nov 24, 2023

Let me propose a default transaction mode, which is used as a transaction mode when mode argument of SQLite3::Database#transaction is omitted.

This pull request does not break compatibility with the current version because the default value of default_transaction_mode is :deferred.

Usage:

db = SQLite3::Database.new "database.db", default_transaction_mode: :immediate
db.transaction  # "begin immediate transaction" is issued.
db.commit
db.transaction :deferred  # "begin deferred transaction" is issued.
db.commit

This pull request also enables us to set the default transaction mode to IMMEDIATE or EXCLUSIVE in rails.

Regards,
Murase

@flavorjones
Copy link
Member

@masamitsu-murase Thank you for suggesting this feature! I'm not familiar with how the Rails adapter is evolving, but this seems like a reasonable change. I've kicked off CI.

@masamitsu-murase
Copy link
Contributor Author

Thank you so much!

* Add "default_transaction_mode" to "options" parameter of
  SQLite3::Database.new.
  It is used as transaction mode when SQLite3::Database#transaction is
  called without "mode" argument.
@flavorjones flavorjones force-pushed the support_default_transaction_mode branch from 34ff624 to 109b6b1 Compare November 26, 2023 17:23
@flavorjones
Copy link
Member

@masamitsu-murase I've rebased onto origin/master to address the truffleruby-head failures, which are unrelated to this PR.

@flavorjones flavorjones merged commit ad93a6b into sparklemotion:master Nov 26, 2023
96 of 97 checks passed
@flavorjones
Copy link
Member

Link to related upstream rails discussion: rails/rails#49849

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants