diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-09 11:19:25 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-09 11:19:25 -0800 |
commit | d1387a994283d6f4a7dce8fdcb22119b276eed72 (patch) | |
tree | 21923b91b5bee9dbeb05bbb71342c926b89249a2 /activerecord/lib/active_record | |
parent | 6110b0c54dde6251f7501e6421a7002a99779537 (diff) | |
parent | 16d7ba0698ef28efab31940ba4d3aed237814c7e (diff) | |
download | rails-d1387a994283d6f4a7dce8fdcb22119b276eed72.tar.gz rails-d1387a994283d6f4a7dce8fdcb22119b276eed72.tar.bz2 rails-d1387a994283d6f4a7dce8fdcb22119b276eed72.zip |
Merge remote branch 'rude/disable-keys-for-postgres-9.0.1' into pg
* 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
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index ccc5085b84..a4b1aa7154 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -404,10 +404,7 @@ module ActiveRecord # 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: @@ -956,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 |