aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJason King <jk@silentcow.com>2009-02-26 16:51:38 +1100
committerMichael Koziarski <michael@koziarski.com>2009-03-02 18:46:30 +1300
commit38136f86dc5504bde94dc7399d4a854023d7481f (patch)
tree7dec0dde7ab422ac33b698f28fcab40f064ede15 /activerecord
parent04fdb6eccb3a49b26bdbf779031f427da23a8bb4 (diff)
downloadrails-38136f86dc5504bde94dc7399d4a854023d7481f.tar.gz
rails-38136f86dc5504bde94dc7399d4a854023d7481f.tar.bz2
rails-38136f86dc5504bde94dc7399d4a854023d7481f.zip
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]
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb21
1 files changed, 20 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
index 5390f49f04..8373163e56 100644
--- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
@@ -72,10 +72,29 @@ module ActiveRecord
#
# * <tt>:database</tt> - Path to the database file.
class SQLiteAdapter < AbstractAdapter
+
+ class Version
+ include Comparable
+ def initialize(vs)
+ @v = vs.split('.').map(&:to_i)
+ end
+ def <=>(rhs)
+ @v <=> rhs.split('.').map(&:to_i)
+ end
+ end
+
def adapter_name #:nodoc:
'SQLite'
end
+ def supports_ddl_transactions?
+ sqlite_version >= '2.0.0'
+ end
+
+ def supports_savepoints?
+ sqlite_version >= '3.6.8'
+ end
+
def supports_migrations? #:nodoc:
true
end
@@ -380,7 +399,7 @@ module ActiveRecord
end
def sqlite_version
- @sqlite_version ||= select_value('select sqlite_version(*)')
+ @sqlite_version ||= SQLiteAdapter::Version.new(select_value('select sqlite_version(*)'))
end
def default_primary_key_type