提交 83247916 编写于 作者: R Ryuta Kamizono

`references(:developers_projects_join)` isn't needed if using `where` with hash condition

上级 5eed3bba
......@@ -697,24 +697,13 @@ def test_habtm_respects_select_query_method
end
def test_join_table_alias
# FIXME: `references` has no impact on the aliases generated for the join
# query. The fact that we pass `:developers_projects_join` to `references`
# and that the SQL string contains `developers_projects_join` is merely a
# coincidence.
assert_equal(
3,
Developer.references(:developers_projects_join).merge(
includes: { projects: :developers },
where: "projects_developers_projects_join.joined_on IS NOT NULL"
).to_a.size
Developer.includes(projects: :developers).where.not("projects_developers_projects_join.joined_on": nil).to_a.size
)
end
def test_join_with_group
# FIXME: `references` has no impact on the aliases generated for the join
# query. The fact that we pass `:developers_projects_join` to `references`
# and that the SQL string contains `developers_projects_join` is merely a
# coincidence.
group = Developer.columns.inject([]) do |g, c|
g << "developers.#{c.name}"
g << "developers_projects_2.#{c.name}"
......@@ -723,10 +712,7 @@ def test_join_with_group
assert_equal(
3,
Developer.references(:developers_projects_join).merge(
includes: { projects: :developers }, where: "projects_developers_projects_join.joined_on IS NOT NULL",
group: group.join(",")
).to_a.size
Developer.includes(projects: :developers).where.not("projects_developers_projects_join.joined_on": nil).group(group.join(",")).to_a.size
)
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册