Sha256: 0b4672ea8cce0ad199becfa76b97d1baff879fc84ea77f6cf37aa921d536e374
Contents?: true
Size: 1.34 KB
Versions: 3
Compression:
Stored size: 1.34 KB
Contents
class ActiveRecord::Base class << self def sqlite3_connection(config) begin require 'jdbc/sqlite3' ::Jdbc::SQLite3.load_driver(:require) if defined?(::Jdbc::SQLite3.load_driver) rescue LoadError # assuming driver.jar is on the class-path end parse_sqlite3_config!(config) database = config[:database] database = '' if database == ':memory:' config[:url] ||= "jdbc:sqlite:#{database}" config[:driver] ||= defined?(::Jdbc::SQLite3.driver_name) ? ::Jdbc::SQLite3.driver_name : 'org.sqlite.JDBC' config[:adapter_class] = ActiveRecord::ConnectionAdapters::SQLite3Adapter config[:adapter_spec] = ::ArJdbc::SQLite3 jdbc_connection(config) end alias_method :jdbcsqlite3_connection, :sqlite3_connection def parse_sqlite3_config!(config) config[:database] ||= config[:dbfile] # Allow database path relative to RAILS_ROOT, but only if # the database path is not the special path that tells # Sqlite to build a database only in memory. rails_root_defined = defined?(Rails.root) || Object.const_defined?(:RAILS_ROOT) if rails_root_defined && ':memory:' != config[:database] rails_root = defined?(Rails.root) ? Rails.root : RAILS_ROOT config[:database] = File.expand_path(config[:database], rails_root) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems