aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
diff options
context:
space:
mode:
authorkennyj <kennyj@gmail.com>2013-03-01 01:55:20 +0900
committerJon Leighton <j@jonathanleighton.com>2013-03-20 10:11:07 +0000
commitdc2bc388bc8c6c345337052bf0d60f5243d899d4 (patch)
tree3f4ec4d6873f1ab94af33fe37701d46e0a43f8cf /activerecord/lib/active_record/connection_adapters
parentbe913c3964069fa9ff7c8a615e06705e3a6ec435 (diff)
downloadrails-dc2bc388bc8c6c345337052bf0d60f5243d899d4.tar.gz
rails-dc2bc388bc8c6c345337052bf0d60f5243d899d4.tar.bz2
rails-dc2bc388bc8c6c345337052bf0d60f5243d899d4.zip
Wrong exception is occured when raising no translatable exception
Conflicts: activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index f01dcec7be..cbbb195458 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -1144,6 +1144,8 @@ module ActiveRecord
UNIQUE_VIOLATION = "23505"
def translate_exception(exception, message)
+ return exception unless exception.respond_to?(:result)
+
case exception.result.try(:error_field, PGresult::PG_DIAG_SQLSTATE)
when UNIQUE_VIOLATION
RecordNotUnique.new(message, exception)