Skip to content

Commit 38136f8

Browse files
smathyNZKoz
authored andcommitted
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]
1 parent 04fdb6e commit 38136f8

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,29 @@ def binary_to_string(value)
7272
#
7373
# * <tt>:database</tt> - Path to the database file.
7474
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+
7586
def adapter_name #:nodoc:
7687
'SQLite'
7788
end
7889

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+
7998
def supports_migrations? #:nodoc:
8099
true
81100
end
@@ -380,7 +399,7 @@ def catch_schema_changes
380399
end
381400

382401
def sqlite_version
383-
@sqlite_version ||= select_value('select sqlite_version(*)')
402+
@sqlite_version ||= SQLiteAdapter::Version.new(select_value('select sqlite_version(*)'))
384403
end
385404

386405
def default_primary_key_type

0 commit comments

Comments
 (0)