Not applied fixed issue #6397 to every tagged and released version. #8952

Closed
nagahoge opened this Issue Jan 15, 2013 · 2 comments

2 participants

@nagahoge

In current master branch e709134, an issue of #6397 (#6397) has been fixed.

postgresql_adapter.rb in master

    # 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.result.try(:error_field, PGresult::PG_DIAG_SQLSTATE)
      when UNIQUE_VIOLATION
        RecordNotUnique.new(message, exception)
      when FOREIGN_KEY_VIOLATION
        InvalidForeignKey.new(message, exception)
      else
        super
      end
    end

But translate_exception method of all v3.x.x tagged versions, and gem-gettable versions are not fixed.

postgresql_adapter.rb in v3.2.11

    def translate_exception(exception, message)
      case exception.message
      when /duplicate key value violates unique constraint/
        RecordNotUnique.new(message, exception)
      when /violates foreign key constraint/
        InvalidForeignKey.new(message, exception)
      else
        super
      end
    end

I think that fixed code should be released.

@carlosantoniodasilva
Ruby on Rails member

As seen in that issue, the code has been applied to 3-2-stable branch, but note released in 3.2.10 or 3.2.11 because those were security releases. It should be available in the next 3.2.x release, which has no release date yet, but shouldn't take long I believe. Thanks!

@nagahoge

Thanks for your reply. I understood.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment