Skip to content

Commit

Permalink
Remove support for SQLite 2.
Browse files Browse the repository at this point in the history
If you're still using it, please install the plugin from git://github.com/rails/sqlite2_adapter.git
  • Loading branch information
lifo committed Aug 17, 2009
1 parent ff1b0d3 commit 25e5b0c
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 107 deletions.
13 changes: 4 additions & 9 deletions activemodel/test/cases/tests_database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,10 @@ def self.setup_schema

def self.setup_connection
defaults = { :database => ':memory:' }
begin
adapter = defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3'
options = defaults.merge :adapter => adapter, :timeout => 500
ActiveRecord::Base.establish_connection(options)
rescue Exception
$stderr.puts 'SQLite 3 unavailable; trying SQLite 2.'
options = defaults.merge :adapter => 'sqlite'
ActiveRecord::Base.establish_connection(options)
end

adapter = defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3'
options = defaults.merge :adapter => adapter, :timeout => 500
ActiveRecord::Base.establish_connection(options)
end
end
end
2 changes: 2 additions & 0 deletions activerecord/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*Edge*

* Remove support for SQLite 2. Please upgrade to SQLite 3+ or install the plugin from git://github.com/rails/sqlite2_adapter.git [Pratik Naik]

* PostgreSQL: XML datatype support. #1874 [Leonardo Borges]

* quoted_date converts time-like objects to ActiveRecord::Base.default_timezone before serialization. This allows you to use Time.now in find conditions and have it correctly be serialized as the current time in UTC when default_timezone == :utc. #2946 [Geoff Buesing]
Expand Down
2 changes: 1 addition & 1 deletion activerecord/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ task :isolated_test => defined?(JRUBY_VERSION) ?
%w(isolated_test_jdbcmysql isolated_test_jdbcsqlite3 isolated_test_jdbcpostgresql) :
%w(isolated_test_mysql isolated_test_sqlite3 isolated_test_postgresql)

%w( mysql postgresql sqlite sqlite3 firebird db2 oracle sybase openbase frontbase jdbcmysql jdbcpostgresql jdbcsqlite3 jdbcderby jdbch2 jdbchsqldb ).each do |adapter|
%w( mysql postgresql sqlite3 firebird db2 oracle sybase openbase frontbase jdbcmysql jdbcpostgresql jdbcsqlite3 jdbcderby jdbch2 jdbchsqldb ).each do |adapter|
Rake::TestTask.new("test_#{adapter}") { |t|
connection_path = "test/connections/#{adapter =~ /jdbc/ ? 'jdbc' : 'native'}_#{adapter}"
adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z]+/]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ def self.sqlite3_connection(config) # :nodoc:

module ConnectionAdapters #:nodoc:
class SQLite3Adapter < SQLiteAdapter # :nodoc:
def table_structure(table_name)
structure = @connection.table_info(quote_table_name(table_name))
raise(ActiveRecord::StatementInvalid, "Could not find table '#{table_name}'") if structure.empty?
structure
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,6 @@
module ActiveRecord
class Base
class << self
# Establishes a connection to the database that's used by all Active Record objects
def sqlite_connection(config) # :nodoc:
parse_sqlite_config!(config)

unless self.class.const_defined?(:SQLite)
require_library_or_gem(config[:adapter])

db = SQLite::Database.new(config[:database], 0)
db.show_datatypes = "ON" if !defined? SQLite::Version
db.results_as_hash = true if defined? SQLite::Version
db.type_translation = false

# "Downgrade" deprecated sqlite API
if SQLite.const_defined?(:Version)
ConnectionAdapters::SQLite2Adapter.new(db, logger, config)
else
ConnectionAdapters::DeprecatedSQLiteAdapter.new(db, logger, config)
end
end
end

private
def parse_sqlite_config!(config)
# Require database.
Expand Down Expand Up @@ -328,9 +307,9 @@ def select(sql, name = nil) #:nodoc:
end

def table_structure(table_name)
returning structure = execute("PRAGMA table_info(#{quote_table_name(table_name)})") do
raise(ActiveRecord::StatementInvalid, "Could not find table '#{table_name}'") if structure.empty?
end
structure = @connection.table_info(quote_table_name(table_name))
raise(ActiveRecord::StatementInvalid, "Could not find table '#{table_name}'") if structure.empty?
structure
end

def alter_table(table_name, options = {}) #:nodoc:
Expand Down Expand Up @@ -445,18 +424,5 @@ def translate_exception(exception, message)
end

end

class SQLite2Adapter < SQLiteAdapter # :nodoc:
def rename_table(name, new_name)
move_table(name, new_name)
end
end

class DeprecatedSQLiteAdapter < SQLite2Adapter # :nodoc:
def insert(sql, name = nil, pk = nil, id_value = nil)
execute(sql, name = nil)
id_value || @connection.last_insert_rowid
end
end
end
end
18 changes: 8 additions & 10 deletions activerecord/test/cases/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1775,17 +1775,15 @@ def test_count_with_join

assert_equal res4, res5

unless current_adapter?(:SQLite2Adapter, :DeprecatedSQLiteAdapter)
res6 = Post.count_by_sql "SELECT COUNT(DISTINCT p.id) FROM posts p, comments co WHERE p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id"
res7 = nil
assert_nothing_raised do
res7 = Post.count(:conditions => "p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id",
:joins => "p, comments co",
:select => "p.id",
:distinct => true)
end
assert_equal res6, res7
res6 = Post.count_by_sql "SELECT COUNT(DISTINCT p.id) FROM posts p, comments co WHERE p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id"
res7 = nil
assert_nothing_raised do
res7 = Post.count(:conditions => "p.#{QUOTED_TYPE} = 'Post' AND p.id=co.post_id",
:joins => "p, comments co",
:select => "p.id",
:distinct => true)
end
assert_equal res6, res7
end

def test_clear_association_cache_stored
Expand Down
25 changes: 0 additions & 25 deletions activerecord/test/connections/native_sqlite/connection.rb

This file was deleted.

2 changes: 1 addition & 1 deletion railties/lib/generators/rails/app/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module Rails::Generators
class AppGenerator < Base
DATABASES = %w( mysql oracle postgresql sqlite2 sqlite3 frontbase ibm_db )
DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
add_shebang_option!

argument :app_path, :type => :string
Expand Down

This file was deleted.

0 comments on commit 25e5b0c

Please sign in to comment.