Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-rychlewski committed Oct 18, 2024
1 parent 9ad0fc8 commit dde27f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/ecto/adapters/myxql_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,12 @@ defmodule Ecto.Adapters.MyXQLTest do
assert all(query) == ~s{SELECT coalesce(s0.`x`, 5) FROM `schema` AS s0}
end

test "coalesce with subquery" do
squery = from s in Schema, select: s.x
query = Schema |> select([s], coalesce(subquery(squery), 5)) |> plan()
assert all(query) == ~s{SELECT coalesce((SELECT ss0.`x` AS `x` FROM `schema` AS ss0), 5) FROM `schema` AS s0}
end

test "where" do
query = Schema |> where([r], r.x == 42) |> where([r], r.y != 43) |> select([r], r.x) |> plan()

Expand Down
6 changes: 6 additions & 0 deletions test/ecto/adapters/postgres_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,12 @@ defmodule Ecto.Adapters.PostgresTest do
assert all(query) == ~s{SELECT coalesce(s0."x", 5) FROM "schema" AS s0}
end

test "coalesce with subquery" do
squery = from s in Schema, select: s.x
query = Schema |> select([s], coalesce(subquery(squery), 5)) |> plan()
assert all(query) == ~s{SELECT coalesce((SELECT ss0."x" AS "x" FROM "schema" AS ss0), 5) FROM "schema" AS s0}
end

test "where" do
query = Schema |> where([r], r.x == 42) |> where([r], r.y != 43) |> select([r], r.x) |> plan()

Expand Down

0 comments on commit dde27f4

Please sign in to comment.