mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05: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:
parent
fbdef7aafe
commit
9d65390805
2 changed files with 14 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue