Skip to content
This repository
Browse code

Make SQLite3 pass the unit tests for savepoints.

  • Loading branch information...
commit 885c11b8f9e18f34b12076023455e72166365f00 1 parent e981eaa
Hongli Lai authored October 09, 2008
6  activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -65,6 +65,12 @@ def supports_count_distinct?
65 65
       def supports_ddl_transactions?
66 66
         false
67 67
       end
  68
+      
  69
+      # Does this adapter support savepoints? PostgreSQL and MySQL do, SQLite
  70
+      # does not.
  71
+      def supports_savepoints?
  72
+        false
  73
+      end
68 74
 
69 75
       # Should primary key values be selected from their corresponding
70 76
       # sequence before the insert statement?  If true, next_sequence_value
4  activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -205,6 +205,10 @@ def adapter_name #:nodoc:
205 205
       def supports_migrations? #:nodoc:
206 206
         true
207 207
       end
  208
+      
  209
+      def supports_savepoints? #:nodoc:
  210
+        true
  211
+      end
208 212
 
209 213
       def native_database_types #:nodoc:
210 214
         NATIVE_DATABASE_TYPES
4  activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -272,6 +272,10 @@ def supports_insert_with_returning?
272 272
       def supports_ddl_transactions?
273 273
         true
274 274
       end
  275
+      
  276
+      def supports_savepoints?
  277
+        true
  278
+      end
275 279
 
276 280
       # Returns the configured supported identifier length supported by PostgreSQL,
277 281
       # or report the default of 63 on PostgreSQL 7.x.
8  activerecord/test/cases/transactions_test.rb
@@ -239,7 +239,7 @@ def test_force_savepoint_in_nested_transaction
239 239
 
240 240
     assert @first.reload.approved?
241 241
     assert !@second.reload.approved?
242  
-  end
  242
+  end if Topic.connection.supports_savepoints?
243 243
 
244 244
   def test_no_savepoint_in_nested_transaction_without_force
245 245
     Topic.transaction do
@@ -260,7 +260,7 @@ def test_no_savepoint_in_nested_transaction_without_force
260 260
 
261 261
     assert !@first.reload.approved?
262 262
     assert !@second.reload.approved?
263  
-  end
  263
+  end if Topic.connection.supports_savepoints?
264 264
   
265 265
   def test_many_savepoints
266 266
     Topic.transaction do
@@ -304,7 +304,7 @@ def test_many_savepoints
304 304
     assert_equal "One", @one
305 305
     assert_equal "Two", @two
306 306
     assert_equal "Three", @three
307  
-  end
  307
+  end if Topic.connection.supports_savepoints?
308 308
 
309 309
   uses_mocha 'mocking connection.commit_db_transaction' do
310 310
     def test_rollback_when_commit_raises
@@ -411,7 +411,7 @@ def test_no_automatic_savepoint_for_inner_transaction
411 411
 
412 412
     assert !@first.reload.approved?
413 413
   end
414  
-end
  414
+end if Topic.connection.supports_savepoints?
415 415
 
416 416
 if current_adapter?(:PostgreSQLAdapter)
417 417
   class ConcurrentTransactionTest < TransactionTest

0 notes on commit 885c11b

Please sign in to comment.
Something went wrong with that request. Please try again.