Skip to content

Error messages broken (undefined method `error_field') #20

Closed
tylerhunt opened this Issue Oct 23, 2012 · 2 comments

2 participants

@tylerhunt

I'm getting the following error message whenever an error is raised by the adapter:

irb> User.find(:missing)
NoMethodError: undefined method `error_field' for #<PGresult:0x007fbd7589fed8>
    from /Users/thunt/Work/redeemable/promofly/.bundle/gems/activesupport-3.2.8/lib/active_support/core_ext/object/try.rb:36:in `try'
    from /Users/thunt/Work/redeemable/promofly/.bundle/gems/pg_power-1.1.0/lib/pg_power/connection_adapters/postgresql_adapter/translate_exception.rb:9:in `translate_exception'
    from /Users/thunt/Work/redeemable/promofly/.bundle/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1150:in `translate_exception'
[…]

This should be raising an error like this instead:

ActiveRecord::StatementInvalid: PGError: ERROR:  invalid input syntax for integer: "missing"

But pg_power is breaking this somehow.

Here are the relevant Gem versions:

activerecord (3.2.8)
pg (0.14.0)
pg_power (1.1.0)
@greyblake

Thanks for the report.

Unfortunately I'm not able to reproduce the error(ruby1.9.3, ruby1.8.7):

User.find(:missing)
  User Load (0.4ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", :missing]]
PG::Error: ERROR:  invalid input syntax for integer: "missing"

@tylerhunt can you provide more information about environment(ruby version and OS) and steps to reproduce?

@tylerhunt

I did some more testing on a fresh app and discovered that the pg version reported above was incorrect. The Gemfile.lock had actually frozen it at 0.11.0. Updating to the 0.14 series seems to resolve the issue. Sorry for the confusion and the wasted cycles.

@tylerhunt tylerhunt closed this Oct 24, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.