Closed hx closed 8 years ago
Closed by PR https://github.com/jackc/edge/pull/15
I am still running into this on jRuby. MRI seems to be fine though.
[11] pry(main)> ActiveRecord.version
=> Gem::Version.new("4.2.5")
[12] pry(main)> exit
~reppro|rails4.2⚡ ⇒ rails c
Loading development environment (Rails 4.2.5)
[1] pry(main)> ActiveRecord.version
=> Gem::Version.new("4.2.5")
[2] pry(main)> Edge::VERSION
=> "0.4.3"
[4] pry(main)> Prompt.where(name: "Universal Questions").find_forest
Prompt Load (3.0ms) WITH RECURSIVE "all_nodes" AS ( SELECT "prompts"."id", "prompts"."parent_id" FROM "prompts" WHERE "prompts"."name" = ? UNION SELECT "prompts"."id", "prompts"."parent_id" FROM "prompts" INNER JOIN "all_nodes" ON "prompts"."parent_id" = "all_nodes"."id" ) SELECT * FROM "all_nodes" INNER JOIN "prompts" ON "all_nodes"."id" = "prompts"."id" ORDER BY position
ActiveRecord::StatementInvalid: ActiveRecord::JDBCError: org.postgresql.util.PSQLException: ERROR: bind message supplies 0 parameters, but prepared statement "" requires 1: WITH RECURSIVE "all_nodes" AS ( SELECT "prompts"."id", "prompts"."parent_id" FROM "prompts" WHERE "prompts"."name" = ? UNION SELECT "prompts"."id", "prompts"."parent_id" FROM "prompts" INNER JOIN "all_nodes" ON "prompts"."parent_id" = "all_nodes"."id" ) SELECT * FROM "all_nodes" INNER JOIN "prompts" ON "all_nodes"."id" = "prompts"."id" ORDER BY position
from arjdbc/jdbc/RubyJdbcConnection.java:888:in `execute_query'
I think the culprit may be: https://github.com/jackc/edge/blob/master/lib/edge/forest.rb#L56
I don't have a JRuby install handy at the moment. Do the tests pass on JRuby?
I installed JRuby and there are failing tests revealing this problem. It turns out that the MRI pg gem and JRuby's PostgreSQL adapter process bind variables at different times. It's a bit of a hack but edge now tries to detect JRuby and handle binds differently.
Just released v0.4.4 with the fix.
Awesome! Thanks, sorry I didn't see your earlier response.
Some have suggested https://github.com/rails/rails/issues/20236 is caused by edge unscoping and re-binding values around https://github.com/jackc/edge/blob/master/lib/edge/forest.rb#L97-L102. Is there another way to achieve this?