Reputation: 1534
I'm getting this exception when I try to update one of my models:
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: missing FROM-clause entry for table "id"
LINE 1: ...M "options" WHERE "options"."product_id" = $1 AND "id"."name...
^
: SELECT "options".* FROM "options" WHERE "options"."product_id" = $1 AND "id"."name" = $2 LIMIT $3
from /Users/mikeyhew/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.0.beta2/lib/active_record/connection_adapters/postgresql_adapter.rb:634:in `prepare'
Using this exception, how can I see the full SQL query that was invalid?
Upvotes: 1
Views: 92
Reputation: 1534
Here's how I managed to find the invalid sql statement: I opened the file where the exception was coming from, and put a debugger statement on the line right before the exception is raised.
I was hoping that either the StatementInvalid exception or the PG::UndefinedTable exception would have the actual sql code as one of their instance variables, but that wasn't the case.
Upvotes: 1