Skip to content
This repository
Browse code

DDL transactions and savepoints for sqlite

Sqlite has had DDL transactions since 2.0.0[1] and savepoints since
3.6.8[2].  This patch updates the connection_adapters.

[1] http://tinyurl.com/sqlite-v2-0-0
[2] http://tinyurl.com/sqlite-v3-6-8

Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#2080 state:committed]
  • Loading branch information...
commit 38136f86dc5504bde94dc7399d4a854023d7481f 1 parent 04fdb6e
Jason King authored February 26, 2009 NZKoz committed March 02, 2009
21  activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
@@ -72,10 +72,29 @@ def binary_to_string(value)
72 72
     #
73 73
     # * <tt>:database</tt> - Path to the database file.
74 74
     class SQLiteAdapter < AbstractAdapter
  75
+
  76
+      class Version
  77
+        include Comparable
  78
+        def initialize(vs)
  79
+          @v = vs.split('.').map(&:to_i)
  80
+        end
  81
+        def <=>(rhs)
  82
+          @v <=> rhs.split('.').map(&:to_i)
  83
+        end
  84
+      end
  85
+
75 86
       def adapter_name #:nodoc:
76 87
         'SQLite'
77 88
       end
78 89
 
  90
+      def supports_ddl_transactions?
  91
+        sqlite_version >= '2.0.0'
  92
+      end
  93
+
  94
+      def supports_savepoints?
  95
+        sqlite_version >= '3.6.8'
  96
+      end
  97
+
79 98
       def supports_migrations? #:nodoc:
80 99
         true
81 100
       end
@@ -380,7 +399,7 @@ def catch_schema_changes
380 399
         end
381 400
 
382 401
         def sqlite_version
383  
-          @sqlite_version ||= select_value('select sqlite_version(*)')
  402
+          @sqlite_version ||= SQLiteAdapter::Version.new(select_value('select sqlite_version(*)'))
384 403
         end
385 404
 
386 405
         def default_primary_key_type

0 notes on commit 38136f8

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