Skip to content

Commit

Permalink
Merge remote branch 'rude/disable-keys-for-postgres-9.0.1' into pg
Browse files Browse the repository at this point in the history
* rude/disable-keys-for-postgres-9.0.1:
  Cleaner way to extract the Postgres version
  Fix Bug: disable_referential_integrity doesn't work for postgres 9.0.1
  • Loading branch information
tenderlove committed Dec 9, 2010
2 parents 6110b0c + 16d7ba0 commit d1387a9
Showing 1 changed file with 7 additions and 6 deletions.
Expand Up @@ -404,10 +404,7 @@ def session_auth=(user)
# REFERENTIAL INTEGRITY ====================================

def supports_disable_referential_integrity?() #:nodoc:
version = query("SHOW server_version")[0][0].split('.')
version[0].to_i >= 8 && version[1].to_i >= 1
rescue
return false
postgresql_version >= 80100
end

def disable_referential_integrity #:nodoc:
Expand Down Expand Up @@ -956,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
Expand Down

0 comments on commit d1387a9

Please sign in to comment.