Added encoding qery support for SQLite3 to make rake db:charset work on all databases shipping with Rails 3

This commit is contained in:
Mikel Lindsaar
2010-02-03 18:06:38 +11:00
parent fbdef7aafe
commit 9d65390805
2 changed files with 14 additions and 0 deletions

View File

@@ -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

View File

@@ -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