Skip to content

Commit

Permalink
[postgres] emulate executed begin/commit/rollback tx statement into A…
Browse files Browse the repository at this point in the history
…R's SQL log
  • Loading branch information
kares committed Oct 29, 2015
1 parent 7561486 commit 0a72a92
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 29 additions & 1 deletion lib/arjdbc/postgresql/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,35 @@ def supports_transaction_isolation?(level = nil)
# @override
def supports_views?; true end

# NOTE: handled by JdbcAdapter we override only to have save-point in logs :
# NOTE: handled by JdbcAdapter only to have statements in logs :

# @override
def begin_db_transaction
# PG driver doesn't really do anything on setAutoCommit(false)
# except for commit-ing a previous pending transaction if any
log('/* BEGIN */') { @connection.begin }
end

# @override
def commit_db_transaction
log('COMMIT') { @connection.commit }
end

# @override
def rollback_db_transaction
log('ROLLBACK') { @connection.rollback }
end

# Starts a database transaction.
# @param isolation the transaction isolation to use
# @since 1.3.0
# @override on **AR-4.0**
def begin_isolated_db_transaction(isolation)
name = isolation.to_s.upcase; name.sub!('_', ' ')
log("/* BEGIN */; SET TRANSACTION ISOLATION LEVEL #{name}") do
@connection.begin(isolation)
end
end

# @override
def supports_savepoints?; true end
Expand Down
2 changes: 2 additions & 0 deletions test/db/postgresql/simple_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class PostgreSQLSimpleTest < Test::Unit::TestCase
include CustomSelectTestMethods
include XmlColumnTestMethods

add_ignored_sql '/* BEGIN */' # for DirtyAttributeTests

# @override
def test_truncate
unless defined? JRUBY_VERSION
Expand Down

0 comments on commit 0a72a92

Please sign in to comment.