Permalink
Browse files

Show a warning if the adapter is not supported. Add a noop adapter fo…

…r sqlite
  • Loading branch information...
1 parent 2da4e06 commit e084ffd4304477a8835213f373ab3fddad3a67b3 @matthuhiggins committed Jul 18, 2012
Showing with 12 additions and 1 deletion.
  1. +1 −0 lib/foreigner.rb
  2. +4 −1 lib/foreigner/adapter.rb
  3. +7 −0 lib/foreigner/connection_adapters/noop_adapter.rb
View
@@ -26,6 +26,7 @@ module Migration
Foreigner::Adapter.register 'jdbcmysql', 'foreigner/connection_adapters/mysql2_adapter'
Foreigner::Adapter.register 'postgresql', 'foreigner/connection_adapters/postgresql_adapter'
Foreigner::Adapter.register 'jdbcpostgresql', 'foreigner/connection_adapters/postgresql_adapter'
+Foreigner::Adapter.register 'sqlite3', 'foreigner/connection_adapters/noop_adapter'
require 'foreigner/loader'
require 'foreigner/railtie' if defined?(Rails)
View
@@ -11,11 +11,14 @@ def register(adapter_name, file_name)
def load!
if registered.key?(configured_name)
require registered[configured_name]
+ else
+ p "Database adapter #{configured_name} not supported. Use:\n" +
+ "Foreigner::Adapter.register '#{configured_name}', 'path/to/adapter'"
end
end
def configured_name
- ActiveRecord::Base.connection_pool.spec.config[:adapter]
+ @configured_name ||= ActiveRecord::Base.connection_pool.spec.config[:adapter]
end
end
end
@@ -0,0 +1,7 @@
+module Foreigner
+ module ConnectionAdapters
+ module NoopAdapter
+ # Used mainly for sqlite3
+ end
+ end
+end

0 comments on commit e084ffd

Please sign in to comment.