{"action":"created","issue":{"url":"https://api.github.com/repos/take-five/activerecord-hierarchical_query/issues/21","repository_url":"https://api.github.com/repos/take-five/activerecord-hierarchical_query","labels_url":"https://api.github.com/repos/take-five/activerecord-hierarchical_query/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/take-five/activerecord-hierarchical_query/issues/21/comments","events_url":"https://api.github.com/repos/take-five/activerecord-hierarchical_query/issues/21/events","html_url":"https://github.com/take-five/activerecord-hierarchical_query/issues/21","id":226743777,"node_id":"MDU6SXNzdWUyMjY3NDM3Nzc=","number":21,"title":"ActiveRecord::StatementInvalid errors with v1.0.0 and Rails 5","user":{"login":"xtagon","id":47229,"node_id":"MDQ6VXNlcjQ3MjI5","avatar_url":"https://avatars0.githubusercontent.com/u/47229?v=4","gravatar_id":"","url":"https://api.github.com/users/xtagon","html_url":"https://github.com/xtagon","followers_url":"https://api.github.com/users/xtagon/followers","following_url":"https://api.github.com/users/xtagon/following{/other_user}","gists_url":"https://api.github.com/users/xtagon/gists{/gist_id}","starred_url":"https://api.github.com/users/xtagon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xtagon/subscriptions","organizations_url":"https://api.github.com/users/xtagon/orgs","repos_url":"https://api.github.com/users/xtagon/repos","events_url":"https://api.github.com/users/xtagon/events{/privacy}","received_events_url":"https://api.github.com/users/xtagon/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2017-05-06T06:25:34Z","updated_at":"2018-09-23T00:05:57Z","closed_at":"2018-09-22T14:09:24Z","author_association":"NONE","body":"Hi,\r\n\r\nI'm trying to use v1.0.0 with Rails 5, and my queries don't quite work. I could really use some help.\r\n\r\nThis does what is expected (gets the ancestors as a relation):\r\n\r\n```ruby\r\nrelation = self.class.join_recursive do |query|\r\n  query.start_with(id: id).connect_by(parent_organization_id: :id)\r\nend\r\n```\r\n\r\nand if I call `#to_a` on that, I get the correct results. However, if I do any of these things:\r\n\r\n`relation.first`, `relation.where(...)`, `relation.limit(...)`, `relation.order(..)` I get an error like this:\r\n\r\n```\r\nActiveRecord::StatementInvalid: PG::ProtocolViolation: ERROR:  bind message supplies 1 parameters, but prepared statement \"a3\" requires 2\r\n```\r\n\r\nHere's an example of the generated SQL when it fails to on `relation.first`:\r\n\r\n```sql\r\nSELECT \"organizations\".* FROM \"organizations\"\r\nINNER JOIN\r\n  (WITH RECURSIVE \"organizations__recursive\" AS\r\n     (SELECT \"organizations\".\"id\", \"organizations\".\"parent_organization_id\"\r\n      FROM \"organizations\"\r\n      WHERE \"organizations\".\"deleted_at\" IS NULL\r\n        AND \"organizations\".\"id\" = $1\r\n        UNION ALL\r\n        SELECT \"organizations\".\"id\",\r\n               \"organizations\".\"parent_organization_id\"\r\n        FROM \"organizations\"\r\n        INNER JOIN \"organizations__recursive\" ON \"organizations__recursive\".\"parent_organization_id\" = \"organizations\".\"id\" WHERE \"organizations\".\"deleted_at\" IS NULL ) SELECT \"organizations__recursive\".*\r\n   FROM \"organizations__recursive\") AS \"organizations__recursive\" ON \"organizations\".\"id\" = \"organizations__recursive\".\"id\"\r\nWHERE \"organizations\".\"deleted_at\" IS NULL\r\nORDER BY \"organizations\".\"id\" ASC\r\nLIMIT $2\r\n```\r\n\r\nAny ideas? Thanks in advance!"},"comment":{"url":"https://api.github.com/repos/take-five/activerecord-hierarchical_query/issues/comments/423781954","html_url":"https://github.com/take-five/activerecord-hierarchical_query/issues/21#issuecomment-423781954","issue_url":"https://api.github.com/repos/take-five/activerecord-hierarchical_query/issues/21","id":423781954,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMzc4MTk1NA==","user":{"login":"xtagon","id":47229,"node_id":"MDQ6VXNlcjQ3MjI5","avatar_url":"https://avatars0.githubusercontent.com/u/47229?v=4","gravatar_id":"","url":"https://api.github.com/users/xtagon","html_url":"https://github.com/xtagon","followers_url":"https://api.github.com/users/xtagon/followers","following_url":"https://api.github.com/users/xtagon/following{/other_user}","gists_url":"https://api.github.com/users/xtagon/gists{/gist_id}","starred_url":"https://api.github.com/users/xtagon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xtagon/subscriptions","organizations_url":"https://api.github.com/users/xtagon/orgs","repos_url":"https://api.github.com/users/xtagon/repos","events_url":"https://api.github.com/users/xtagon/events{/privacy}","received_events_url":"https://api.github.com/users/xtagon/received_events","type":"User","site_admin":false},"created_at":"2018-09-23T00:05:57Z","updated_at":"2018-09-23T00:05:57Z","author_association":"NONE","body":"Sounds fair. It is going to take me a little longer to reproduce again as I'm fixing some conflicts in the branch I was working in. I'll re-open the issue when it gets to that point."}}
{"actor":{"display_login":"xtagon"}}