From 2b39cf4a1d8dde8011c26cab0a6bcc5415eff3da Mon Sep 17 00:00:00 2001 From: lizconlan Date: Tue, 7 Feb 2017 12:22:50 +0000 Subject: [PATCH] Add new private method to DatabaseCollation to retrieve db encoding --- lib/database_collation.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/database_collation.rb b/lib/database_collation.rb index 9716ea3475a..5753ee56328 100644 --- a/lib/database_collation.rb +++ b/lib/database_collation.rb @@ -59,6 +59,13 @@ def supported_collations map { |row| row['collname'] } end + def database_encoding + @database_encoding ||= connection.execute("SELECT encoding FROM " \ + "pg_database WHERE datname = " \ + "'#{connection.current_database}';"). + first["encoding"] + end + def adapter_name @adapter_name ||= connection.adapter_name end