Permalink
Browse files

Cleaner way to extract the Postgres version

  • Loading branch information...
1 parent d9ac62c commit 16d7ba0698ef28efab31940ba4d3aed237814c7e @matthewrudy matthewrudy committed Nov 21, 2010
Showing with 6 additions and 2 deletions.
  1. +6 −2 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -953,8 +953,12 @@ def postgresql_version
else
# Mimic PGconn.server_version behavior
begin
- query('SELECT version()')[0][0] =~ /PostgreSQL (\d+)\.(\d+)\.(\d+)/
- ($1.to_i * 10000) + ($2.to_i * 100) + $3.to_i
+ if query('SELECT version()')[0][0] =~ /PostgreSQL ([0-9.]+)/
+ major, minor, tiny = $1.split(".")
+ (major.to_i * 10000) + (minor.to_i * 100) + tiny.to_i
+ else
+ 0
+ end
rescue
0
end

0 comments on commit 16d7ba0

Please sign in to comment.