Skip to content

Commit

Permalink
Add new private method to DatabaseCollation to retrieve db encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
lizconlan committed Feb 8, 2017
1 parent 857ee1c commit 13eeb25
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/database_collation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ def supported_collations
map { |row| row['collname'] }
end

def database_encoding
sql = <<-EOF.strip_heredoc.squish
SELECT encoding FROM pg_database
WHERE datname = '#{ connection.current_database }';
EOF

@database_encoding ||= connection.execute(sql).first["encoding"]
end

def adapter_name
@adapter_name ||= connection.adapter_name
end
Expand Down

0 comments on commit 13eeb25

Please sign in to comment.