{"action":"created","issue":{"url":"https://api.github.com/repos/elixir-ecto/ecto/issues/2472","repository_url":"https://api.github.com/repos/elixir-ecto/ecto","labels_url":"https://api.github.com/repos/elixir-ecto/ecto/issues/2472/labels{/name}","comments_url":"https://api.github.com/repos/elixir-ecto/ecto/issues/2472/comments","events_url":"https://api.github.com/repos/elixir-ecto/ecto/issues/2472/events","html_url":"https://github.com/elixir-ecto/ecto/pull/2472","id":307782606,"number":2472,"title":"Queries in Associations","user":{"login":"zachdaniel","id":5722339,"avatar_url":"https://avatars1.githubusercontent.com/u/5722339?v=4","gravatar_id":"","url":"https://api.github.com/users/zachdaniel","html_url":"https://github.com/zachdaniel","followers_url":"https://api.github.com/users/zachdaniel/followers","following_url":"https://api.github.com/users/zachdaniel/following{/other_user}","gists_url":"https://api.github.com/users/zachdaniel/gists{/gist_id}","starred_url":"https://api.github.com/users/zachdaniel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zachdaniel/subscriptions","organizations_url":"https://api.github.com/users/zachdaniel/orgs","repos_url":"https://api.github.com/users/zachdaniel/repos","events_url":"https://api.github.com/users/zachdaniel/events{/privacy}","received_events_url":"https://api.github.com/users/zachdaniel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2018-03-22T19:25:37Z","updated_at":"2018-03-24T09:15:28Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/elixir-ecto/ecto/pulls/2472","html_url":"https://github.com/elixir-ecto/ecto/pull/2472","diff_url":"https://github.com/elixir-ecto/ecto/pull/2472.diff","patch_url":"https://github.com/elixir-ecto/ecto/pull/2472.patch"},"body":"There wasn't much to do to make this work as expected, because everything aside from the validations was expecting associations to be expressed as queryables anyway (as far as I can tell). I have a few test failures that I'm not 100% sure on, but they appear to be due to changes I made to test schemas. I didn't want to just change them off hand though, because for all I know I broke something real. So I left those tests failing, and wrote new tests to express both the capability of building the query with queries for assocs, and the planning of it. I was going to write integration tests for it, but I figured that if the planner is breaking it out into the correct joins, that it would be unnecessary to have an integration test.\r\n\r\nThis is in service of providing a lot of the value #2395 was looking for, without having to introduce the larger change of default where clauses."},"comment":{"url":"https://api.github.com/repos/elixir-ecto/ecto/issues/comments/375858758","html_url":"https://github.com/elixir-ecto/ecto/pull/2472#issuecomment-375858758","issue_url":"https://api.github.com/repos/elixir-ecto/ecto/issues/2472","id":375858758,"user":{"login":"josevalim","id":9582,"avatar_url":"https://avatars0.githubusercontent.com/u/9582?v=4","gravatar_id":"","url":"https://api.github.com/users/josevalim","html_url":"https://github.com/josevalim","followers_url":"https://api.github.com/users/josevalim/followers","following_url":"https://api.github.com/users/josevalim/following{/other_user}","gists_url":"https://api.github.com/users/josevalim/gists{/gist_id}","starred_url":"https://api.github.com/users/josevalim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josevalim/subscriptions","organizations_url":"https://api.github.com/users/josevalim/orgs","repos_url":"https://api.github.com/users/josevalim/repos","events_url":"https://api.github.com/users/josevalim/events{/privacy}","received_events_url":"https://api.github.com/users/josevalim/received_events","type":"User","site_admin":false},"created_at":"2018-03-24T09:15:28Z","updated_at":"2018-03-24T09:15:28Z","author_association":"OWNER","body":"@zachdaniel I have noticed that you are relying on the join queries for subqueries. This is actually quite interesting because it means it should be possible to lift the where restriction.\r\n\r\nBut before we lift any restriction, which I don't think we should now anyway, do you think we will have a difference in performance? Imagine those two queries:\r\n\r\n    from s in Summary, join: p in ^(from p in Post, where: p.upvotes >= 1000), on: p.summary_id == s.id\r\n\r\n    from s in Summary, join: p in Post, on: p.summary_id == s.id and p.upvotes >= 1000\r\n\r\nWhich one would be more efficient? Or is it not relevant enough to matter? Could you please investigate by analyzing the generated SQL?"}}
{"actor":{"display_login":"josevalim"}}