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

sqlite3: Allow users to disable implicit transactions #350

Merged
merged 3 commits into from
Mar 3, 2020
Merged

sqlite3: Allow users to disable implicit transactions #350

merged 3 commits into from
Mar 3, 2020

Conversation

saj
Copy link
Contributor

@saj saj commented Feb 28, 2020

Fixes #346.

An sqlite3 database may be opened with the x-no-tx-wrap=true query
parameter if the user would prefer to retain full control over the
bounds of their transactions.  With x-no-tx-wrap enabled, migrations
should contain explicit BEGIN and COMMIT statements.  This (optional)
behaviour for the sqlite3 driver is consistent with the default
behaviour for other drivers.

Fixes #346.
@coveralls
Copy link

coveralls commented Feb 28, 2020

Pull Request Test Coverage Report for Build 707

  • 16 of 18 (88.89%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 52.509%

Changes Missing Coverage Covered Lines Changed/Added Lines %
database/sqlite3/sqlite3.go 16 18 88.89%
Totals Coverage Status
Change from base Build 705: 0.1%
Covered Lines: 2511
Relevant Lines: 4782

💛 - Coveralls

Copy link
Member

@dhui dhui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR and for writing the README!


noTxWrap, err := strconv.ParseBool(qv.Get("x-no-tx-wrap"))
if err != nil {
noTxWrap = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's cleaner to return an error for invalid values. We should handle non-existent (e.g. unspecified) values separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did wonder about this, so I went looking for existing patterns. I found this behaviour in the cockroachdb driver. Would you still prefer an error -- at the cost of consistency -- in this case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's cleaner to fail for invalid inputs instead of silently assuming a value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have pushed a commit with the change you requested. PTAL, @dhui.

@dhui dhui merged commit 39cc097 into golang-migrate:master Mar 3, 2020
@saj saj deleted the saj/sqlite-no-implicit-tx branch March 3, 2020 13:32
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.

sqlite: Migrations are always wrapped in implicit transactions
3 participants