mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Added encoding qery support for SQLite3 to make rake db:charset work on all databases shipping with Rails 3
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user