Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-rychlewski committed Sep 21, 2023
1 parent b4881ef commit 7c29243
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions test/ecto/adapters/sqlite3/connection/union_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,24 @@ defmodule Ecto.Adapters.SQLite3.Connection.UnionTest do
end

test "parent binding subquery and combination" do
right_query = from(c in "right_categories", where: c.id == parent_as(:c).id, select: c.id)
left_query = from(c in "left_categories", where: c.id == parent_as(:c).id, select: c.id)
right_query =
from(c in "right_categories", where: c.id == parent_as(:c).id, select: c.id)

left_query =
from(c in "left_categories", where: c.id == parent_as(:c).id, select: c.id)

union_query = union(left_query, ^right_query)
query = from(c in "categories", as: :c, where: c.id in subquery(union_query), select: c.id) |> plan()

query =
from(c in "categories", as: :c, where: c.id in subquery(union_query), select: c.id)
|> plan()

assert all(query) ==
~s{SELECT c0."id" FROM "categories" AS c0 } <>
~s{WHERE (} <>
~s{c0."id" IN } <>
~s{(SELECT sl0."id" FROM "left_categories" AS sl0 WHERE (sl0."id" = c0."id") } <>
~s{UNION } <>
~s{SELECT sr0."id" FROM "right_categories" AS sr0 WHERE (sr0."id" = c0."id")))}
~s{SELECT c0."id" FROM "categories" AS c0 } <>
~s{WHERE (} <>
~s{c0."id" IN } <>
~s{(SELECT sl0."id" FROM "left_categories" AS sl0 WHERE (sl0."id" = c0."id") } <>
~s{UNION } <>
~s{SELECT sr0."id" FROM "right_categories" AS sr0 WHERE (sr0."id" = c0."id")))}
end
end

0 comments on commit 7c29243

Please sign in to comment.