Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Fixed adapter class lookup for default sqlite database.yml
Browse files Browse the repository at this point in the history
The official rails templates changed the adapter
name to 'sqlite' in the created database.yml file.
We need to account for that in dm-rails and we
agreed upon calling it sqlite in DM land anyway.
  • Loading branch information
snusnu committed Jun 14, 2010
1 parent e0e01bd commit a29c607
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/dm-rails/storage.rb
Expand Up @@ -47,7 +47,7 @@ def with_local_repositories
end

def lookup_class(adapter)
klass_name = adapter.camelize.to_sym
klass_name = normalized_adapter_name(adapter).camelize.to_sym

unless Storage.const_defined?(klass_name)
raise "Adapter #{adapter} not supported (#{klass_name.inspect})"
Expand All @@ -56,6 +56,10 @@ def lookup_class(adapter)
const_get(klass_name)
end

def normalized_adapter_name(adapter_name)
adapter_name.to_s == 'sqlite3' ? 'sqlite' : adapter_name
end

end

def initialize(name, config)
Expand Down Expand Up @@ -88,7 +92,7 @@ def charset
@charset ||= config['charset'] || ENV['CHARSET'] || 'utf8'
end

class Sqlite3 < Storage
class Sqlite < Storage
def _create
return if in_memory?
::DataMapper.setup(name, config.merge('database' => path))
Expand Down

0 comments on commit a29c607

Please sign in to comment.