diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-03-20 16:41:01 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-03-20 16:41:01 -0700 |
commit | d1577cfe3d7f01f2876e3cbe682065012246697c (patch) | |
tree | 0fc5512f74f2c4938c0853d7444fc7112a695c8a /activerecord/lib | |
parent | 38d06478614adcf68a45947cb162c3152e2d7bb1 (diff) | |
parent | 2c8f34995378e4a18711cf5f947e8465227d3748 (diff) | |
download | rails-d1577cfe3d7f01f2876e3cbe682065012246697c.tar.gz rails-d1577cfe3d7f01f2876e3cbe682065012246697c.tar.bz2 rails-d1577cfe3d7f01f2876e3cbe682065012246697c.zip |
Merge branch '3-2-stable' into fredwu-slow_view_loading_fix
* 3-2-stable:
Merge pull request #9802 from newsline/fix-broken-action-missing
Remove bad changelog entry from AR [ci skip]
Wrong exception is occured when raising no translatable exception
Don't crash exception translation w/ nil result attribute.
Conflicts:
actionpack/CHANGELOG.md
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 8806693397..cbbb195458 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -1144,7 +1144,9 @@ module ActiveRecord UNIQUE_VIOLATION = "23505" def translate_exception(exception, message) - case exception.result.error_field(PGresult::PG_DIAG_SQLSTATE) + return exception unless exception.respond_to?(:result) + + case exception.result.try(:error_field, PGresult::PG_DIAG_SQLSTATE) when UNIQUE_VIOLATION RecordNotUnique.new(message, exception) when FOREIGN_KEY_VIOLATION |