From 0dbf5e3517336a0386341548bfb81028c7831bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Juc=C3=A1?= Date: Sun, 7 May 2023 18:05:17 -0300 Subject: [PATCH] Add missing `:on` keys to queries with joins --- .../ecto/adapters/sqlite3/connection_test.exs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/test/ecto/adapters/sqlite3/connection_test.exs b/test/ecto/adapters/sqlite3/connection_test.exs index b34d6ea..d5f7eb9 100644 --- a/test/ecto/adapters/sqlite3/connection_test.exs +++ b/test/ecto/adapters/sqlite3/connection_test.exs @@ -307,6 +307,7 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do from(c in "categories", as: :parent_category, left_lateral_join: b in subquery(breadcrumbs_query), + on: true, select: %{id: c.id, breadcrumbs: b.breadcrumbs} ) |> plan() @@ -1409,7 +1410,10 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do test "join with hints" do assert_raise Ecto.QueryError, ~r/join hints are not supported by SQLite3/, fn -> Schema - |> join(:inner, [p], q in Schema2, hints: ["USE INDEX FOO", "USE INDEX BAR"]) + |> join(:inner, [p], q in Schema2, + hints: ["USE INDEX FOO", "USE INDEX BAR"], + on: true + ) |> select([], true) |> plan() |> all() @@ -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) |> select([_, p], p) |> plan() @@ -1519,7 +1523,8 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do "SELECT * FROM schema2 AS s2 WHERE s2.id = ? AND s2.field = ?", p.x, ^10 - ) + ), + on: true ) |> select([p], {p.id, ^0}) |> where([p], p.id > 0 and p.id < ^100) @@ -1545,7 +1550,10 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do test "join with query interpolation" do inner = Ecto.Queryable.to_query(Schema2) - query = from(p in Schema, left_join: c in ^inner, select: {p.id, c.id}) |> plan() + + query = + from(p in Schema, left_join: c in ^inner, on: true, select: {p.id, c.id}) + |> plan() assert all(query) == "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 "SELECT * FROM schema2 AS s2 WHERE s2.id = ? AND s2.field = ?", p.x, ^10 - ) + ), + on: true ) |> select([p, q], {p.id, q.z}) |> where([p], p.id > 0 and p.id < ^100)