Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…on all databases shipping with Rails 3
  • Loading branch information...
commit 9d653908059523bc2e3e1e646c0bcd4ebe5a80d7 1 parent fbdef7a
@mikel mikel authored
View
11 activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
@@ -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
View
3  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
Please sign in to comment.
Something went wrong with that request. Please try again.