aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_controller/routing/route_set.rb12
-rw-r--r--actionpack/test/abstract_unit.rb3
-rw-r--r--actionpack/test/controller/action_pack_assertions_test.rb8
-rw-r--r--actionpack/test/controller/base_test.rb34
-rw-r--r--actionpack/test/controller/caching_test.rb3
-rw-r--r--actionpack/test/controller/mime_responds_test.rb1
-rw-r--r--actionpack/test/controller/redirect_test.rb24
-rw-r--r--actionpack/test/controller/render_test.rb18
-rw-r--r--actionpack/test/controller/render_xml_test.rb14
-rw-r--r--actionpack/test/controller/request_forgery_protection_test.rb6
-rw-r--r--actionpack/test/controller/routing_test.rb3
-rw-r--r--actionpack/test/controller/test_test.rb6
-rw-r--r--actionpack/test/controller/url_rewriter_test.rb141
-rw-r--r--actionpack/test/controller/verification_test.rb5
-rw-r--r--activemodel/test/cases/tests_database.rb13
-rw-r--r--activerecord/CHANGELOG2
-rw-r--r--activerecord/Rakefile2
-rw-r--r--activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb5
-rw-r--r--activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb40
-rwxr-xr-xactiverecord/test/cases/base_test.rb18
-rw-r--r--activerecord/test/connections/native_sqlite/connection.rb25
-rw-r--r--railties/lib/generators/rails/app/app_generator.rb2
-rw-r--r--railties/lib/generators/rails/app/templates/config/databases/sqlite2.yml19
23 files changed, 158 insertions, 246 deletions
diff --git a/actionpack/lib/action_controller/routing/route_set.rb b/actionpack/lib/action_controller/routing/route_set.rb
index a4f54ad662..25fdbf480e 100644
--- a/actionpack/lib/action_controller/routing/route_set.rb
+++ b/actionpack/lib/action_controller/routing/route_set.rb
@@ -213,7 +213,7 @@ module ActionController
self.routes = []
self.named_routes = NamedRouteCollection.new
- clear_recognize_optimized!
+ clear!
end
# Subclasses and plugins may override this method to specify a different
@@ -223,6 +223,7 @@ module ActionController
end
def draw
+ clear!
yield Mapper.new(self)
install_helpers
end
@@ -230,8 +231,10 @@ module ActionController
def clear!
routes.clear
named_routes.clear
+
@combined_regexp = nil
@routes_by_controller = nil
+
# This will force routing/recognition_optimization.rb
# to refresh optimisations.
clear_recognize_optimized!
@@ -262,7 +265,6 @@ module ActionController
def load!
Routing.use_controllers!(nil) # Clear the controller cache so we may discover new ones
- clear!
load_routes!
end
@@ -286,10 +288,12 @@ module ActionController
configuration_files.each { |config| load(config) }
@routes_last_modified = routes_changed_at
else
- add_route ":controller/:action/:id"
+ draw do |map|
+ map.connect ":controller/:action/:id"
+ end
end
end
-
+
def routes_changed_at
routes_changed_at = nil
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index eb4e2fb585..a21b00915e 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -70,12 +70,13 @@ module ActionController
class TestCase
include TestProcess
+
setup do
ActionController::Routing::Routes.draw do |map|
map.connect ':controller/:action/:id'
end
end
-
+
def assert_template(options = {}, message = nil)
validate_request!
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index ecbaba39d1..06827e5fbc 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -185,13 +185,9 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
# let's get this party started
def setup
super
- ActionController::Routing::Routes.reload
- ActionController::Routing.use_controllers!(%w(action_pack_assertions admin/inner_module user content admin/user))
- end
- def teardown
- super
- ActionController::Routing::Routes.reload
+ ActionController::Routing.use_controllers!(%w(action_pack_assertions admin/inner_module user content admin/user))
+ ActionController::Routing::Routes.load_routes!
end
# -- assertion-based testing ------------------------------------------------
diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb
index 8877057070..b97ceb4594 100644
--- a/actionpack/test/controller/base_test.rb
+++ b/actionpack/test/controller/base_test.rb
@@ -177,17 +177,17 @@ class DefaultUrlOptionsTest < ActionController::TestCase
end
def test_default_url_options_are_used_if_set
- ActionController::Routing::Routes.draw do |map|
- map.default_url_options 'default_url_options', :controller => 'default_url_options'
- map.connect ':controller/:action/:id'
- end
+ with_routing do |set|
+ set.draw do |map|
+ map.default_url_options 'default_url_options', :controller => 'default_url_options'
+ map.connect ':controller/:action/:id'
+ end
- get :default_url_options_action # Make a dummy request so that the controller is initialized properly.
+ get :default_url_options_action # Make a dummy request so that the controller is initialized properly.
- assert_equal 'http://www.override.com/default_url_options/new?bacon=chunky', @controller.url_for(:controller => 'default_url_options')
- assert_equal 'http://www.override.com/default_url_options?bacon=chunky', @controller.send(:default_url_options_url)
- ensure
- ActionController::Routing::Routes.load!
+ assert_equal 'http://www.override.com/default_url_options/new?bacon=chunky', @controller.url_for(:controller => 'default_url_options')
+ assert_equal 'http://www.override.com/default_url_options?bacon=chunky', @controller.send(:default_url_options_url)
+ end
end
end
@@ -206,15 +206,15 @@ class EmptyUrlOptionsTest < ActionController::TestCase
end
end
-class EnsureNamedRoutesWorksTicket22BugTest < Test::Unit::TestCase
+class EnsureNamedRoutesWorksTicket22BugTest < ActionController::TestCase
def test_named_routes_still_work
- ActionController::Routing::Routes.draw do |map|
- map.resources :things
- end
- EmptyController.send :include, ActionController::UrlWriter
+ with_routing do |set|
+ set.draw do |map|
+ map.resources :things
+ end
+ EmptyController.send :include, ActionController::UrlWriter
- assert_equal '/things', EmptyController.new.send(:things_path)
- ensure
- ActionController::Routing::Routes.load!
+ assert_equal '/things', EmptyController.new.send(:things_path)
+ end
end
end
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index f1c93e6b1e..82c790bc19 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -48,8 +48,6 @@ class PageCachingTest < ActionController::TestCase
super
ActionController::Base.perform_caching = true
- ActionController::Routing::Routes.clear!
-
ActionController::Routing::Routes.draw do |map|
map.main '', :controller => 'posts', :format => nil
map.formatted_posts 'posts.:format', :controller => 'posts'
@@ -72,7 +70,6 @@ class PageCachingTest < ActionController::TestCase
def teardown
FileUtils.rm_rf(File.dirname(FILE_STORE_PATH))
- ActionController::Routing::Routes.clear!
ActionController::Base.perform_caching = false
end
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index 3f00b9ba2f..44536ce54e 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -531,6 +531,7 @@ class RespondWithControllerTest < ActionController::TestCase
ActionController::Routing::Routes.draw do |map|
map.resources :customers
map.resources :quiz_stores, :has_many => :customers
+ map.connect ":controller/:action/:id"
end
end
diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb
index 7755af592d..ea278fd8f0 100644
--- a/actionpack/test/controller/redirect_test.rb
+++ b/actionpack/test/controller/redirect_test.rb
@@ -231,18 +231,20 @@ class RedirectTest < ActionController::TestCase
end
def test_redirect_to_record
- ActionController::Routing::Routes.draw do |map|
- map.resources :workshops
- map.connect ':controller/:action/:id'
+ with_routing do |set|
+ set.draw do |map|
+ map.resources :workshops
+ map.connect ':controller/:action/:id'
+ end
+
+ get :redirect_to_existing_record
+ assert_equal "http://test.host/workshops/5", redirect_to_url
+ assert_redirected_to Workshop.new(5, false)
+
+ get :redirect_to_new_record
+ assert_equal "http://test.host/workshops", redirect_to_url
+ assert_redirected_to Workshop.new(5, true)
end
-
- get :redirect_to_existing_record
- assert_equal "http://test.host/workshops/5", redirect_to_url
- assert_redirected_to Workshop.new(5, false)
-
- get :redirect_to_new_record
- assert_equal "http://test.host/workshops", redirect_to_url
- assert_redirected_to Workshop.new(5, true)
end
def test_redirect_to_nil
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index 9c5b560c2c..abcc8bf384 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -1086,15 +1086,17 @@ class RenderTest < ActionController::TestCase
end
def test_head_with_location_object
- ActionController::Routing::Routes.draw do |map|
- map.resources :customers
- map.connect ':controller/:action/:id'
- end
+ with_routing do |set|
+ set.draw do |map|
+ map.resources :customers
+ map.connect ':controller/:action/:id'
+ end
- get :head_with_location_object
- assert @response.body.blank?
- assert_equal "http://www.nextangle.com/customers/1", @response.headers["Location"]
- assert_response :ok
+ get :head_with_location_object
+ assert @response.body.blank?
+ assert_equal "http://www.nextangle.com/customers/1", @response.headers["Location"]
+ assert_response :ok
+ end
end
def test_head_with_custom_header
diff --git a/actionpack/test/controller/render_xml_test.rb b/actionpack/test/controller/render_xml_test.rb
index 139f55d8bd..e96e8a4d57 100644
--- a/actionpack/test/controller/render_xml_test.rb
+++ b/actionpack/test/controller/render_xml_test.rb
@@ -55,13 +55,15 @@ class RenderTest < ActionController::TestCase
end
def test_rendering_with_object_location_should_set_header_with_url_for
- ActionController::Routing::Routes.draw do |map|
- map.resources :customers
- map.connect ':controller/:action/:id'
- end
+ with_routing do |set|
+ set.draw do |map|
+ map.resources :customers
+ map.connect ':controller/:action/:id'
+ end
- get :render_with_object_location
- assert_equal "http://www.nextangle.com/customers/1", @response.headers["Location"]
+ get :render_with_object_location
+ assert_equal "http://www.nextangle.com/customers/1", @response.headers["Location"]
+ end
end
def test_should_render_formatted_xml_erb_template
diff --git a/actionpack/test/controller/request_forgery_protection_test.rb b/actionpack/test/controller/request_forgery_protection_test.rb
index 83925ed4db..7111796f8d 100644
--- a/actionpack/test/controller/request_forgery_protection_test.rb
+++ b/actionpack/test/controller/request_forgery_protection_test.rb
@@ -1,10 +1,6 @@
require 'abstract_unit'
require 'digest/sha1'
-ActionController::Routing::Routes.draw do |map|
- map.connect ':controller/:action/:id'
-end
-
# common controller actions
module RequestForgeryProtectionActions
def index
@@ -50,7 +46,7 @@ module RequestForgeryProtectionTests
def teardown
ActionController::Base.request_forgery_protection_token = nil
end
-
+
def test_should_render_form_with_token_tag
get :index
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 33fb6ac017..5be780dd42 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -102,8 +102,7 @@ class RoutingTest < Test::Unit::TestCase
ActionController::Routing.use_controllers! true_possible_controllers
Object.send(:remove_const, :RAILS_ROOT) rescue nil
- ActionController::Routing::Routes.clear!
- ActionController::Routing::Routes.load_routes!
+ ActionController::Routing::Routes.reload!
end
def test_with_controllers
diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb
index 9e88188b9a..84c97851ee 100644
--- a/actionpack/test/controller/test_test.rb
+++ b/actionpack/test/controller/test_test.rb
@@ -123,15 +123,11 @@ XML
@controller = TestController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
+
ActionController::Routing.use_controllers! %w(content admin/user test_test/test)
ActionController::Routing::Routes.load_routes!
end
- def teardown
- super
- ActionController::Routing::Routes.reload
- end
-
def test_raw_post_handling
params = {:page => {:name => 'page name'}, 'some key' => 123}
post :render_raw_post, params.dup
diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb
index 0e149cf8ae..ad915e7a57 100644
--- a/actionpack/test/controller/url_rewriter_test.rb
+++ b/actionpack/test/controller/url_rewriter_test.rb
@@ -195,61 +195,62 @@ class UrlWriterTests < ActionController::TestCase
end
def test_named_routes
- ActionController::Routing::Routes.draw do |map|
- map.no_args '/this/is/verbose', :controller => 'home', :action => 'index'
- map.home '/home/sweet/home/:user', :controller => 'home', :action => 'index'
- map.connect ':controller/:action/:id'
+ with_routing do |set|
+ set.draw do |map|
+ map.no_args '/this/is/verbose', :controller => 'home', :action => 'index'
+ map.home '/home/sweet/home/:user', :controller => 'home', :action => 'index'
+ map.connect ':controller/:action/:id'
+ end
+
+ # We need to create a new class in order to install the new named route.
+ kls = Class.new { include ActionController::UrlWriter }
+ controller = kls.new
+ assert controller.respond_to?(:home_url)
+ assert_equal 'http://www.basecamphq.com/home/sweet/home/again',
+ controller.send(:home_url, :host => 'www.basecamphq.com', :user => 'again')
+
+ assert_equal("/home/sweet/home/alabama", controller.send(:home_path, :user => 'alabama', :host => 'unused'))
+ assert_equal("http://www.basecamphq.com/home/sweet/home/alabama", controller.send(:home_url, :user => 'alabama', :host => 'www.basecamphq.com'))
+ assert_equal("http://www.basecamphq.com/this/is/verbose", controller.send(:no_args_url, :host=>'www.basecamphq.com'))
end
-
- # We need to create a new class in order to install the new named route.
- kls = Class.new { include ActionController::UrlWriter }
- controller = kls.new
- assert controller.respond_to?(:home_url)
- assert_equal 'http://www.basecamphq.com/home/sweet/home/again',
- controller.send(:home_url, :host => 'www.basecamphq.com', :user => 'again')
-
- assert_equal("/home/sweet/home/alabama", controller.send(:home_path, :user => 'alabama', :host => 'unused'))
- assert_equal("http://www.basecamphq.com/home/sweet/home/alabama", controller.send(:home_url, :user => 'alabama', :host => 'www.basecamphq.com'))
- assert_equal("http://www.basecamphq.com/this/is/verbose", controller.send(:no_args_url, :host=>'www.basecamphq.com'))
- ensure
- ActionController::Routing::Routes.load!
end
def test_relative_url_root_is_respected_for_named_routes
orig_relative_url_root = ActionController::Base.relative_url_root
ActionController::Base.relative_url_root = '/subdir'
- ActionController::Routing::Routes.draw do |map|
- map.home '/home/sweet/home/:user', :controller => 'home', :action => 'index'
- end
+ with_routing do |set|
+ set.draw do |map|
+ map.home '/home/sweet/home/:user', :controller => 'home', :action => 'index'
+ end
- kls = Class.new { include ActionController::UrlWriter }
- controller = kls.new
+ kls = Class.new { include ActionController::UrlWriter }
+ controller = kls.new
- assert_equal 'http://www.basecamphq.com/subdir/home/sweet/home/again',
- controller.send(:home_url, :host => 'www.basecamphq.com', :user => 'again')
+ assert_equal 'http://www.basecamphq.com/subdir/home/sweet/home/again',
+ controller.send(:home_url, :host => 'www.basecamphq.com', :user => 'again')
+ end
ensure
- ActionController::Routing::Routes.load!
ActionController::Base.relative_url_root = orig_relative_url_root
end
def test_only_path
- ActionController::Routing::Routes.draw do |map|
- map.home '/home/sweet/home/:user', :controller => 'home', :action => 'index'
- map.connect ':controller/:action/:id'
+ with_routing do |set|
+ set.draw do |map|
+ map.home '/home/sweet/home/:user', :controller => 'home', :action => 'index'
+ map.connect ':controller/:action/:id'
+ end
+
+ # We need to create a new class in order to install the new named route.
+ kls = Class.new { include ActionController::UrlWriter }
+ controller = kls.new
+ assert controller.respond_to?(:home_url)
+ assert_equal '/brave/new/world',
+ controller.send(:url_for, :controller => 'brave', :action => 'new', :id => 'world', :only_path => true)
+
+ assert_equal("/home/sweet/home/alabama", controller.send(:home_url, :user => 'alabama', :host => 'unused', :only_path => true))
+ assert_equal("/home/sweet/home/alabama", controller.send(:home_path, 'alabama'))
end
-
- # We need to create a new class in order to install the new named route.
- kls = Class.new { include ActionController::UrlWriter }
- controller = kls.new
- assert controller.respond_to?(:home_url)
- assert_equal '/brave/new/world',
- controller.send(:url_for, :controller => 'brave', :action => 'new', :id => 'world', :only_path => true)
-
- assert_equal("/home/sweet/home/alabama", controller.send(:home_url, :user => 'alabama', :host => 'unused', :only_path => true))
- assert_equal("/home/sweet/home/alabama", controller.send(:home_path, 'alabama'))
- ensure
- ActionController::Routing::Routes.load!
end
def test_one_parameter
@@ -302,41 +303,41 @@ class UrlWriterTests < ActionController::TestCase
end
def test_named_routes_with_nil_keys
- ActionController::Routing::Routes.clear!
- ActionController::Routing::Routes.draw do |map|
- map.main '', :controller => 'posts', :format => nil
- map.resources :posts
- map.connect ':controller/:action/:id'
+ with_routing do |set|
+ set.draw do |map|
+ map.main '', :controller => 'posts', :format => nil
+ map.resources :posts
+ map.connect ':controller/:action/:id'
+ end
+
+ # We need to create a new class in order to install the new named route.
+ kls = Class.new { include ActionController::UrlWriter }
+ kls.default_url_options[:host] = 'www.basecamphq.com'
+
+ controller = kls.new
+ params = {:action => :index, :controller => :posts, :format => :xml}
+ assert_equal("http://www.basecamphq.com/posts.xml", controller.send(:url_for, params))
+ params[:format] = nil
+ assert_equal("http://www.basecamphq.com/", controller.send(:url_for, params))
end
- # We need to create a new class in order to install the new named route.
- kls = Class.new { include ActionController::UrlWriter }
- kls.default_url_options[:host] = 'www.basecamphq.com'
-
- controller = kls.new
- params = {:action => :index, :controller => :posts, :format => :xml}
- assert_equal("http://www.basecamphq.com/posts.xml", controller.send(:url_for, params))
- params[:format] = nil
- assert_equal("http://www.basecamphq.com/", controller.send(:url_for, params))
- ensure
- ActionController::Routing::Routes.load!
end
def test_formatted_url_methods_are_deprecated
- ActionController::Routing::Routes.draw do |map|
- map.resources :posts
+ with_routing do |set|
+ set.draw do |map|
+ map.resources :posts
+ end
+ # We need to create a new class in order to install the new named route.
+ kls = Class.new { include ActionController::UrlWriter }
+ controller = kls.new
+ params = {:id => 1, :format => :xml}
+ assert_deprecated do
+ assert_equal("/posts/1.xml", controller.send(:formatted_post_path, params))
+ end
+ assert_deprecated do
+ assert_equal("/posts/1.xml", controller.send(:formatted_post_path, 1, :xml))
+ end
end
- # We need to create a new class in order to install the new named route.
- kls = Class.new { include ActionController::UrlWriter }
- controller = kls.new
- params = {:id => 1, :format => :xml}
- assert_deprecated do
- assert_equal("/posts/1.xml", controller.send(:formatted_post_path, params))
- end
- assert_deprecated do
- assert_equal("/posts/1.xml", controller.send(:formatted_post_path, 1, :xml))
- end
- ensure
- ActionController::Routing::Routes.load!
end
def test_multiple_includes_maintain_distinct_options
diff --git a/actionpack/test/controller/verification_test.rb b/actionpack/test/controller/verification_test.rb
index d568030e41..ee558f3465 100644
--- a/actionpack/test/controller/verification_test.rb
+++ b/actionpack/test/controller/verification_test.rb
@@ -112,7 +112,10 @@ class VerificationTest < ActionController::TestCase
tests TestController
setup do
- ActionController::Routing::Routes.add_named_route :foo, '/foo', :controller => 'test', :action => 'foo'
+ ActionController::Routing::Routes.draw do |map|
+ map.foo '/foo', :controller => 'test', :action => 'foo'
+ map.connect ":controller/:action/:id"
+ end
end
def test_using_symbol_back_with_no_referrer
diff --git a/activemodel/test/cases/tests_database.rb b/activemodel/test/cases/tests_database.rb
index 0f4475fa2d..8dd00ea147 100644
--- a/activemodel/test/cases/tests_database.rb
+++ b/activemodel/test/cases/tests_database.rb
@@ -27,15 +27,10 @@ module ActiveModel
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
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index acfd470c95..d8bfb1916d 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -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]
diff --git a/activerecord/Rakefile b/activerecord/Rakefile
index fb3e81066c..c4971e88b0 100644
--- a/activerecord/Rakefile
+++ b/activerecord/Rakefile
@@ -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]+/]
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
index 5eef692d05..d933bc924d 100644
--- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
@@ -24,11 +24,6 @@ module ActiveRecord
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
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
index 4f0b06d1bb..5a49fc2d2f 100644
--- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
@@ -4,27 +4,6 @@ require 'active_support/core_ext/kernel/requires'
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.
@@ -329,9 +308,9 @@ module ActiveRecord
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:
@@ -446,18 +425,5 @@ module ActiveRecord
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
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index 26a475b964..df15c1a797 100755
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -1775,17 +1775,15 @@ class BasicsTest < ActiveRecord::TestCase
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
diff --git a/activerecord/test/connections/native_sqlite/connection.rb b/activerecord/test/connections/native_sqlite/connection.rb
deleted file mode 100644
index fea985d8a3..0000000000
--- a/activerecord/test/connections/native_sqlite/connection.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-print "Using native SQlite\n"
-require_dependency 'models/course'
-require 'logger'
-ActiveRecord::Base.logger = Logger.new("debug.log")
-
-class SqliteError < StandardError
-end
-
-BASE_DIR = FIXTURES_ROOT
-sqlite_test_db = "#{BASE_DIR}/fixture_database.sqlite"
-sqlite_test_db2 = "#{BASE_DIR}/fixture_database_2.sqlite"
-
-def make_connection(clazz, db_file)
- ActiveRecord::Base.configurations = { clazz.name => { :adapter => 'sqlite', :database => db_file } }
- unless File.exist?(db_file)
- puts "SQLite database not found at #{db_file}. Rebuilding it."
- sqlite_command = %Q{sqlite "#{db_file}" "create table a (a integer); drop table a;"}
- puts "Executing '#{sqlite_command}'"
- raise SqliteError.new("Seems that there is no sqlite executable available") unless system(sqlite_command)
- end
- clazz.establish_connection(clazz.name)
-end
-
-make_connection(ActiveRecord::Base, sqlite_test_db)
-make_connection(Course, sqlite_test_db2)
diff --git a/railties/lib/generators/rails/app/app_generator.rb b/railties/lib/generators/rails/app/app_generator.rb
index c80a344e0d..24c9a969f9 100644
--- a/railties/lib/generators/rails/app/app_generator.rb
+++ b/railties/lib/generators/rails/app/app_generator.rb
@@ -4,7 +4,7 @@ require 'rails/version' unless defined?(Rails::VERSION)
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
diff --git a/railties/lib/generators/rails/app/templates/config/databases/sqlite2.yml b/railties/lib/generators/rails/app/templates/config/databases/sqlite2.yml
deleted file mode 100644
index 46f01cb42c..0000000000
--- a/railties/lib/generators/rails/app/templates/config/databases/sqlite2.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-# SQLite version 2.x
-# gem install sqlite-ruby
-development:
- adapter: sqlite
- database: db/development.sqlite2
- pool: 5
-
-# Warning: The database defined as "test" will be erased and
-# re-generated from your development database when you run "rake".
-# Do not set this db to the same as development or production.
-test:
- adapter: sqlite
- database: db/test.sqlite2
- pool: 5
-
-production:
- adapter: sqlite
- database: db/production.sqlite2
- pool: 5