aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorMatthew Rudy Jacobs <MatthewRudyJacobs@gmail.com>2010-11-21 20:45:01 +0800
committerMatthew Rudy Jacobs <MatthewRudyJacobs@gmail.com>2010-11-21 20:45:01 +0800
commit16d7ba0698ef28efab31940ba4d3aed237814c7e (patch)
tree296df83c7dc889e8056dc62049a83d34efb4e382 /activerecord
parentd9ac62c91466e40b557d27c4d712f86759d63a4b (diff)
downloadrails-16d7ba0698ef28efab31940ba4d3aed237814c7e.tar.gz
rails-16d7ba0698ef28efab31940ba4d3aed237814c7e.tar.bz2
rails-16d7ba0698ef28efab31940ba4d3aed237814c7e.zip
Cleaner way to extract the Postgres version
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 7dd81abc7e..a4b1aa7154 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -953,8 +953,12 @@ module ActiveRecord
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