DBSourceDBContextTransaction

class Transaction

A database transaction context that extends Session with transaction management capabilities.

Definitions

def begin

Begin a transaction.

Implementation

def begin
	self.connect!
	self.call("BEGIN")
end

def commit

Commit the transaction and return the connection to the connection pool.

Implementation

def commit
	self.call("COMMIT")
	self.close
end

def commit?

Commit the transaction if it's still open, otherwise do nothing. This is a safe version of commit that checks if the transaction is still active.

Implementation

def commit?
	unless self.closed?
		self.commit
	end
end

def abort

Abort the transaction and return the connection to the connection pool.

Implementation

def abort
	self.call("ROLLBACK")
	self.close
end

def savepoint(name)

Mark a savepoint in the transaction.

Implementation

def savepoint(name)
	self.call("SAVEPOINT #{name}")
end

def rollback(name)

Return back to a previously registered savepoint.

Implementation

def rollback(name)
	self.call("ROLLBACK #{name}")
end