aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorMikel Lindsaar <raasdnil@gmail.com>2010-02-03 18:06:38 +1100
committerMikel Lindsaar <raasdnil@gmail.com>2010-02-03 18:06:38 +1100
commit9d653908059523bc2e3e1e646c0bcd4ebe5a80d7 (patch)
tree700610a986ea19b21ad2af9dcd05167999173c4b /activerecord/lib/active_record
parentfbdef7aafe753d2375b16c5dcf70a463996b929f (diff)
downloadrails-9d653908059523bc2e3e1e646c0bcd4ebe5a80d7.tar.gz
rails-9d653908059523bc2e3e1e646c0bcd4ebe5a80d7.tar.bz2
rails-9d653908059523bc2e3e1e646c0bcd4ebe5a80d7.zip
Added encoding qery support for SQLite3 to make rake db:charset work on all databases shipping with Rails 3
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb11
-rw-r--r--activerecord/lib/active_record/railties/databases.rake3
2 files changed, 14 insertions, 0 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 8ca7c394fd..4343bef3d4 100644
--- a/activerecord/lib/active_record/railties/databases.rake
+++ b/activerecord/lib/active_record/railties/databases.rake
@@ -200,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