-
Notifications
You must be signed in to change notification settings - Fork 52
Add missing :on
keys to queries with joins
#113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -1475,7 +1479,7 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do | |||
query = | |||
"comments" | |||
|> from(as: :comment) | |||
|> join(:inner, [c], p in subquery(posts)) | |||
|> join(:inner, [c], p in subquery(posts), on: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pretty sure this should just be on: p.id == c.post_id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I changed it, the test failed:
$ mix test
..........................................................................................................................................
1) test join with subquery (Ecto.Adapters.SQLite3.ConnectionTest)
test/ecto/adapters/sqlite3/connection_test.exs:1445
Assertion with == failed
code: assert all(query) ==
~s"SELECT s1.\"title\" FROM \"comments\" AS c0 " <>
~s"INNER JOIN (SELECT sp0.\"title\" AS \"title\" FROM \"posts\" AS sp0 WHERE (sp0.\"title\" = c0.\"subtitle\")) AS s1 ON 1"
left: "SELECT s1.\"title\" FROM \"comments\" AS c0 INNER JOIN (SELECT sp0.\"title\" AS \"title\" FROM \"posts\" AS sp0 WHERE (sp0.\"title\" = c0.\"subtitle\")) AS s1 ON s1.\"id\" = c0.\"post_id\""
right: "SELECT s1.\"title\" FROM \"comments\" AS c0 INNER JOIN (SELECT sp0.\"title\" AS \"title\" FROM \"posts\" AS sp0 WHERE (sp0.\"title\" = c0.\"subtitle\")) AS s1 ON 1"
stacktrace:
test/ecto/adapters/sqlite3/connection_test.exs:1486: (test)
...........................................................................................
Finished in 0.7 seconds (0.6s async, 0.09s sync)
230 tests, 1 failure
Randomized with seed 382835
I avoided changing things in test cases to keep it focused on eliminating the warnings. If we should visit these tests, we better do it in another PR (we'll probably touch some other things too).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we should fix the tests here too. I don't see why we can't fix them here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test file has 2.4K lines of code, with multiple modules defined inline and lots of functions defined directly in the test module. I'm not familiar enough with the Ecto.Adapters.SQL.Connection
behaviour just yet, so I can't step up to do any refactoring for now, that's why I kept the PR focused on cleaning up the warnings only.
I've been diving into the Ecto documentation to be able to actively contribute to ecto_sqlite3 since last week. I expect to be able to contribute at a higher level soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joeljuca I'm thinking we should just fix the tests now and those warnings are good indicators of the places we should alter them. When I get some time, I'll either copy your changes or just push into this branch with the SQL updates. It's a good thing to clean up as we go.
Originally I just copied a lot of tests from other adapters and threw together frankenstien tests from all of them to give this library a fighting chance 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, got it. So we leave it as it is for now? What should we do with this PR? Leave it hanging till we're able to refactor these tests, or we just close it and move on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave this open. I can attack this and use the changes you made to hunt down and improve the tests.
@joeljuca I was comparing these tests to what is in the postgres adapter and what you changed to is roughly what they do. So I just merged this and am cleaning up some tests now. |
It's mostly a no-op when it comes to features, etc. – but it eliminates these annoying warnings that get in the way of important
mix test
outputs (tests breaking with insightful information).Before this patch,
mix test
looks like this:After this patch: