On 28 August 2012 17:14, ddoherty03 <ddohert...@gmail.com> wrote: > I have been getting the following exception lately using the postgresql > adapter. It seems to be related to Transactions, since it mentions BEGIN. > I had a model named Transaction, which I thought might be causing the > problem, so I renamed it to Transact. But I still get the error. Something > is generating 'EXPLAIN BEGIN' as the entirety of the SQL statement. > > The rails statement that is running is a dynamic finder: > > >> if v = Violation.find_by_issuer_id_and_filer_id(issuer.id, filer.id) >> v << filing >> >> end > > > > Anyone seen this? Any ideas? > > >> >> /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1158:in >> `async_exec': PG::Error: ERROR: syntax error at or near "BEGIN" >> (ActiveRecord::StatementInvalid) >> LINE 1: EXPLAIN BEGIN >> ^ >> : EXPLAIN BEGIN >> from >> /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1158:in >> `exec_no_cache' >> from >> /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:664:in > ..... /collection_proxy.rb:89:in >> `method_missing' >> from lib/script/find_spvs.rb:25:in `block in <main>' >> from lib/script/find_spvs.rb:22:in `each' >> from lib/script/find_spvs.rb:22:in `<main>'
I assume that find_spvs.rb:25 is if v = Violation.find_by_issuer_id_and_filer_id(issuer.id, filer.id) If I were in that situation I would first extract issuer.id and filer.id to local variables just in case it is evaluating them that is causing a problem, and also put some debug in to print them just in case the values are strange. You have not said whether the Violation class works ok in other situations. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.