1 # Don't need to load native sqlite3 adapter
2 $LOADED_FEATURES << "active_record/connection_adapters/sqlite_adapter.rb"
3 $LOADED_FEATURES << "active_record/connection_adapters/sqlite3_adapter.rb"
5 class ActiveRecord::Base
7 def sqlite3_connection(config)
8 require "arjdbc/sqlite3"
10 parse_sqlite3_config!(config)
11 database = config[:database]
12 database = '' if database == ':memory:'
13 config[:url] ||= "jdbc:sqlite:#{database}"
14 config[:driver] ||= "org.sqlite.JDBC"
15 config[:adapter_class] = ActiveRecord::ConnectionAdapters::SQLite3Adapter
16 jdbc_connection(config)
19 def parse_sqlite3_config!(config)
20 config[:database] ||= config[:dbfile]
22 # Allow database path relative to RAILS_ROOT, but only if
23 # the database path is not the special path that tells
24 # Sqlite to build a database only in memory.
25 rails_root_defined = defined?(Rails.root) || Object.const_defined?(:RAILS_ROOT)
26 if rails_root_defined && ':memory:' != config[:database]
27 rails_root = defined?(Rails.root) ? Rails.root : RAILS_ROOT
28 config[:database] = File.expand_path(config[:database], rails_root)
32 alias_method :jdbcsqlite3_connection, :sqlite3_connection