diff options
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb | 11 | ||||
-rw-r--r-- | activerecord/lib/active_record/railties/databases.rake | 3 |
2 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb index d933bc924d..f295af16f0 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb @@ -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 diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 8ca7c394fd..4343bef3d4 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/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 |