Skip to content

Commit bd96c23

Browse files
authored
Add missing :on keys to queries with joins (#113)
1 parent a476817 commit bd96c23

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

test/ecto/adapters/sqlite3/connection_test.exs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
307307
from(c in "categories",
308308
as: :parent_category,
309309
left_lateral_join: b in subquery(breadcrumbs_query),
310+
on: true,
310311
select: %{id: c.id, breadcrumbs: b.breadcrumbs}
311312
)
312313
|> plan()
@@ -1409,7 +1410,10 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
14091410
test "join with hints" do
14101411
assert_raise Ecto.QueryError, ~r/join hints are not supported by SQLite3/, fn ->
14111412
Schema
1412-
|> join(:inner, [p], q in Schema2, hints: ["USE INDEX FOO", "USE INDEX BAR"])
1413+
|> join(:inner, [p], q in Schema2,
1414+
hints: ["USE INDEX FOO", "USE INDEX BAR"],
1415+
on: true
1416+
)
14131417
|> select([], true)
14141418
|> plan()
14151419
|> all()
@@ -1475,7 +1479,7 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
14751479
query =
14761480
"comments"
14771481
|> from(as: :comment)
1478-
|> join(:inner, [c], p in subquery(posts))
1482+
|> join(:inner, [c], p in subquery(posts), on: true)
14791483
|> select([_, p], p)
14801484
|> plan()
14811485

@@ -1519,7 +1523,8 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
15191523
"SELECT * FROM schema2 AS s2 WHERE s2.id = ? AND s2.field = ?",
15201524
p.x,
15211525
^10
1522-
)
1526+
),
1527+
on: true
15231528
)
15241529
|> select([p], {p.id, ^0})
15251530
|> where([p], p.id > 0 and p.id < ^100)
@@ -1545,7 +1550,10 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
15451550

15461551
test "join with query interpolation" do
15471552
inner = Ecto.Queryable.to_query(Schema2)
1548-
query = from(p in Schema, left_join: c in ^inner, select: {p.id, c.id}) |> plan()
1553+
1554+
query =
1555+
from(p in Schema, left_join: c in ^inner, on: true, select: {p.id, c.id})
1556+
|> plan()
15491557

15501558
assert all(query) ==
15511559
"SELECT s0.\"id\", s1.\"id\" FROM \"schema\" AS s0 LEFT OUTER JOIN \"schema2\" AS s1 ON 1"
@@ -1561,7 +1569,8 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
15611569
"SELECT * FROM schema2 AS s2 WHERE s2.id = ? AND s2.field = ?",
15621570
p.x,
15631571
^10
1564-
)
1572+
),
1573+
on: true
15651574
)
15661575
|> select([p, q], {p.id, q.z})
15671576
|> where([p], p.id > 0 and p.id < ^100)

0 commit comments

Comments
 (0)