{"action":"created","issue":{"url":"https://api.github.com/repos/brianhempel/active_record_union/issues/4","repository_url":"https://api.github.com/repos/brianhempel/active_record_union","labels_url":"https://api.github.com/repos/brianhempel/active_record_union/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/brianhempel/active_record_union/issues/4/comments","events_url":"https://api.github.com/repos/brianhempel/active_record_union/issues/4/events","html_url":"https://github.com/brianhempel/active_record_union/pull/4","id":104491031,"number":4,"title":"union with multiple relations at once, quote table name","user":{"login":"odedniv","id":894198,"avatar_url":"https://avatars.githubusercontent.com/u/894198?v=3","gravatar_id":"","url":"https://api.github.com/users/odedniv","html_url":"https://github.com/odedniv","followers_url":"https://api.github.com/users/odedniv/followers","following_url":"https://api.github.com/users/odedniv/following{/other_user}","gists_url":"https://api.github.com/users/odedniv/gists{/gist_id}","starred_url":"https://api.github.com/users/odedniv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odedniv/subscriptions","organizations_url":"https://api.github.com/users/odedniv/orgs","repos_url":"https://api.github.com/users/odedniv/repos","events_url":"https://api.github.com/users/odedniv/events{/privacy}","received_events_url":"https://api.github.com/users/odedniv/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-09-02T14:17:37Z","updated_at":"2016-03-20T02:41:17Z","closed_at":"2016-03-20T02:41:17Z","pull_request":{"url":"https://api.github.com/repos/brianhempel/active_record_union/pulls/4","html_url":"https://github.com/brianhempel/active_record_union/pull/4","diff_url":"https://github.com/brianhempel/active_record_union/pull/4.diff","patch_url":"https://github.com/brianhempel/active_record_union/pull/4.patch"},"body":"- Lose all the unnecessary outer SELECTs when unioning with N queries.\r\n- Table name needs to be quoted as it may be a reserved database keyword.\r\n- Minor refactoring."},"comment":{"url":"https://api.github.com/repos/brianhempel/active_record_union/issues/comments/198834701","html_url":"https://github.com/brianhempel/active_record_union/pull/4#issuecomment-198834701","issue_url":"https://api.github.com/repos/brianhempel/active_record_union/issues/4","id":198834701,"user":{"login":"brianhempel","id":506950,"avatar_url":"https://avatars.githubusercontent.com/u/506950?v=3","gravatar_id":"","url":"https://api.github.com/users/brianhempel","html_url":"https://github.com/brianhempel","followers_url":"https://api.github.com/users/brianhempel/followers","following_url":"https://api.github.com/users/brianhempel/following{/other_user}","gists_url":"https://api.github.com/users/brianhempel/gists{/gist_id}","starred_url":"https://api.github.com/users/brianhempel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianhempel/subscriptions","organizations_url":"https://api.github.com/users/brianhempel/orgs","repos_url":"https://api.github.com/users/brianhempel/repos","events_url":"https://api.github.com/users/brianhempel/events{/privacy}","received_events_url":"https://api.github.com/users/brianhempel/received_events","type":"User","site_admin":false},"created_at":"2016-03-20T02:41:17Z","updated_at":"2016-03-20T02:41:17Z","body":"Yeah, SQLite doesn't allow associativity grouping. If you remove the parens, this works:\r\n\r\n```sql\r\nSELECT \"posts\".* FROM (\r\n  SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = 1\r\n  UNION\r\n  SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"id\" = 2\r\n  UNION\r\n  SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"id\" = 3\r\n  UNION\r\n  SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"id\" = 4\r\n) \"posts\"\r\n```\r\n\r\nIt's going to be too hack-tastic to do that in this gem though, so I'm going to pass on this."}}