提交 fa41c929 编写于 作者: A Aaron Patterson

Merge pull request #6397 from kennyj/fix_translate_exception

Fix a problem of translate_exception method in a Japanese (non English) environment.
......@@ -1336,11 +1336,15 @@ def postgresql_version
@connection.server_version
end
# See http://www.postgresql.org/docs/9.1/static/errcodes-appendix.html
FOREIGN_KEY_VIOLATION = "23503"
UNIQUE_VIOLATION = "23505"
def translate_exception(exception, message)
case exception.message
when /duplicate key value violates unique constraint/
case exception.result.error_field(PGresult::PG_DIAG_SQLSTATE)
when UNIQUE_VIOLATION
RecordNotUnique.new(message, exception)
when /violates foreign key constraint/
when FOREIGN_KEY_VIOLATION
InvalidForeignKey.new(message, exception)
else
super
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册