Skip to content

Commit

Permalink
Make SQLite3 pass the unit tests for savepoints.
Browse files Browse the repository at this point in the history
  • Loading branch information
FooBarWidget committed Nov 3, 2008
1 parent e981eaa commit 885c11b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
Expand Up @@ -65,6 +65,12 @@ def supports_count_distinct?
def supports_ddl_transactions? def supports_ddl_transactions?
false false
end end

# Does this adapter support savepoints? PostgreSQL and MySQL do, SQLite
# does not.
def supports_savepoints?
false
end


# Should primary key values be selected from their corresponding # Should primary key values be selected from their corresponding
# sequence before the insert statement? If true, next_sequence_value # sequence before the insert statement? If true, next_sequence_value
Expand Down
Expand Up @@ -205,6 +205,10 @@ def adapter_name #:nodoc:
def supports_migrations? #:nodoc: def supports_migrations? #:nodoc:
true true
end end

def supports_savepoints? #:nodoc:
true
end


def native_database_types #:nodoc: def native_database_types #:nodoc:
NATIVE_DATABASE_TYPES NATIVE_DATABASE_TYPES
Expand Down
Expand Up @@ -272,6 +272,10 @@ def supports_insert_with_returning?
def supports_ddl_transactions? def supports_ddl_transactions?
true true
end end

def supports_savepoints?
true
end


# Returns the configured supported identifier length supported by PostgreSQL, # Returns the configured supported identifier length supported by PostgreSQL,
# or report the default of 63 on PostgreSQL 7.x. # or report the default of 63 on PostgreSQL 7.x.
Expand Down
8 changes: 4 additions & 4 deletions activerecord/test/cases/transactions_test.rb
Expand Up @@ -239,7 +239,7 @@ def test_force_savepoint_in_nested_transaction


assert @first.reload.approved? assert @first.reload.approved?
assert !@second.reload.approved? assert !@second.reload.approved?
end end if Topic.connection.supports_savepoints?


def test_no_savepoint_in_nested_transaction_without_force def test_no_savepoint_in_nested_transaction_without_force
Topic.transaction do Topic.transaction do
Expand All @@ -260,7 +260,7 @@ def test_no_savepoint_in_nested_transaction_without_force


assert !@first.reload.approved? assert !@first.reload.approved?
assert !@second.reload.approved? assert !@second.reload.approved?
end end if Topic.connection.supports_savepoints?


def test_many_savepoints def test_many_savepoints
Topic.transaction do Topic.transaction do
Expand Down Expand Up @@ -304,7 +304,7 @@ def test_many_savepoints
assert_equal "One", @one assert_equal "One", @one
assert_equal "Two", @two assert_equal "Two", @two
assert_equal "Three", @three assert_equal "Three", @three
end end if Topic.connection.supports_savepoints?


uses_mocha 'mocking connection.commit_db_transaction' do uses_mocha 'mocking connection.commit_db_transaction' do
def test_rollback_when_commit_raises def test_rollback_when_commit_raises
Expand Down Expand Up @@ -411,7 +411,7 @@ def test_no_automatic_savepoint_for_inner_transaction


assert !@first.reload.approved? assert !@first.reload.approved?
end end
end end if Topic.connection.supports_savepoints?


if current_adapter?(:PostgreSQLAdapter) if current_adapter?(:PostgreSQLAdapter)
class ConcurrentTransactionTest < TransactionTest class ConcurrentTransactionTest < TransactionTest
Expand Down

0 comments on commit 885c11b

Please sign in to comment.