Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/libsql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def transaction
abort = true
raise
ensure
abort and tx.rollback or tx.commit
abort ? tx.rollback : tx.commit
end
end

Expand Down
12 changes: 12 additions & 0 deletions spec/libsql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,16 @@
expect(count).to eq(0)
end
end

describe 'Connection#transaction' do
context 'when there is an exception' do
it 'aborts the transaction and raises the exception' do
exception_class = Class.new(StandardError)

db.connect do |conn|
expect { conn.transaction { raise exception_class } }.to raise_error(exception_class)
end
end
end
end
end