aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-02-03 10:32:27 +0100
committerJosé Valim <jose.valim@gmail.com>2010-02-03 10:32:27 +0100
commitb13504303b26a07f95f26ab6efe41f3bc0740a69 (patch)
treee3b92e910ce71e87487eb31bb091700ddff3ae09 /activerecord
parent80e49354f17853130dd2ae5815d71d192c8ec9d7 (diff)
parentf390eade5fd70615ba2ee8e089821bcf2d5f7b17 (diff)
downloadrails-b13504303b26a07f95f26ab6efe41f3bc0740a69.tar.gz
rails-b13504303b26a07f95f26ab6efe41f3bc0740a69.tar.bz2
rails-b13504303b26a07f95f26ab6efe41f3bc0740a69.zip
Merge remote branch 'mikel/master'
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb11
-rw-r--r--activerecord/lib/active_record/railties/databases.rake9
2 files changed, 19 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
index d933bc924d..f295af16f0 100644
--- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
@@ -24,6 +24,17 @@ module ActiveRecord
module ConnectionAdapters #:nodoc:
class SQLite3Adapter < SQLiteAdapter # :nodoc:
+
+ # Returns the current database encoding format as a string, eg: 'UTF-8'
+ def encoding
+ if @connection.respond_to?(:encoding)
+ @connection.encoding[0]['encoding']
+ else
+ encoding = @connection.send(:get_query_pragma, 'encoding')
+ encoding[0]['encoding']
+ end
+ end
+
end
end
end
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake
index 2ef8676f39..4343bef3d4 100644
--- a/activerecord/lib/active_record/railties/databases.rake
+++ b/activerecord/lib/active_record/railties/databases.rake
@@ -26,8 +26,12 @@ namespace :db do
end
end
- desc 'Create the database defined in config/database.yml for the current Rails.env'
+ desc 'Create the database defined in config/database.yml for the current Rails.env - also makes test database if in development mode'
task :create => :load_config do
+ # Make the test database at the same time as the development one
+ if Rails.env == 'development'
+ create_database(ActiveRecord::Base.configurations['test'])
+ end
create_database(ActiveRecord::Base.configurations[Rails.env])
end
@@ -196,6 +200,9 @@ namespace :db do
when 'postgresql'
ActiveRecord::Base.establish_connection(config)
puts ActiveRecord::Base.connection.encoding
+ when 'sqlite3'
+ ActiveRecord::Base.establish_connection(config)
+ puts ActiveRecord::Base.connection.encoding
else
puts 'sorry, your database adapter is not supported yet, feel free to submit a patch'
end