Permalink
Browse files

Added encoding qery support for SQLite3 to make rake db:charset work …

…on all databases shipping with Rails 3
  • Loading branch information...
1 parent fbdef7a commit 9d653908059523bc2e3e1e646c0bcd4ebe5a80d7 @mikel mikel committed Feb 3, 2010
@@ -24,6 +24,17 @@ def self.sqlite3_connection(config) # :nodoc:
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
@@ -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

0 comments on commit 9d65390

Please sign in to comment.