Skip to content

Commit 0550a3b

Browse files
committed
better test tags, and remove tests that don't produce valid SQL
1 parent 4b51f0a commit 0550a3b

File tree

3 files changed

+9
-33
lines changed

3 files changed

+9
-33
lines changed

integration_test/sql/subquery.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ defmodule Ecto.Integration.SubQueryTest do
113113
assert [12, 12] = TestRepo.all(query)
114114
end
115115

116+
@tag :subquery_in_order_by
116117
test "subqueries in order by" do
117118
TestRepo.insert!(%Post{visits: 10, title: "hello"})
118119
TestRepo.insert!(%Post{visits: 11, title: "hello"})
@@ -123,6 +124,7 @@ defmodule Ecto.Integration.SubQueryTest do
123124
end
124125

125126
@tag :multicolumn_distinct
127+
@tag :subquery_in_distinct
126128
test "subqueries in distinct" do
127129
TestRepo.insert!(%Post{visits: 10, title: "hello1"})
128130
TestRepo.insert!(%Post{visits: 10, title: "hello2"})
@@ -133,6 +135,7 @@ defmodule Ecto.Integration.SubQueryTest do
133135
assert [%{title: "hello"}, %{title: "hello1"}] = TestRepo.all(query)
134136
end
135137

138+
@tag :subquery_in_group_by
136139
test "subqueries in group by" do
137140
TestRepo.insert!(%Post{visits: 10, title: "hello1"})
138141
TestRepo.insert!(%Post{visits: 10, title: "hello2"})

integration_test/tds/test_helper.exs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ ExUnit.start(
5858
:selected_as_with_order_by_expression,
5959
# MSSQL doesn't support specifying columns for ON DELETE SET NULL
6060
:on_delete_nilify_column_list,
61-
# MySQL doesnt' support anything except a single column in DISTINCT
62-
:multicolumn_distinct
61+
# MSSQL doesnt' support anything except a single column in DISTINCT
62+
:multicolumn_distinct,
63+
# MSSQL doesnt' support subqueries in group by or in distinct
64+
:subquery_in_group_by,
65+
:subquery_in_distinct,
66+
:subquery_in_order_by
6367
]
6468
)
6569

test/ecto/adapters/tds_test.exs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -516,22 +516,6 @@ defmodule Ecto.Adapters.TdsTest do
516516
query = Schema |> order_by([r], []) |> select([r], r.x) |> plan()
517517
assert all(query) == ~s{SELECT s0.[x] FROM [schema] AS s0}
518518

519-
query =
520-
from(row in Schema, as: :r)
521-
|> order_by(
522-
asc:
523-
exists(
524-
from other_schema in "schema",
525-
where: other_schema.x == parent_as(:r).x,
526-
select: [other_schema.x]
527-
)
528-
)
529-
|> select([r], r.x)
530-
|> plan()
531-
532-
assert all(query) ==
533-
~s{SELECT s0.[x] FROM [schema] AS s0 ORDER BY exists(SELECT ss0.[x] AS [result] FROM [schema] AS ss0 WHERE (ss0.[x] = s0.[x]))}
534-
535519
for dir <- [:asc_nulls_first, :asc_nulls_last, :desc_nulls_first, :desc_nulls_last] do
536520
assert_raise Ecto.QueryError, ~r"#{dir} is not supported in ORDER BY in MSSQL", fn ->
537521
Schema |> order_by([r], [{^dir, r.x}]) |> select([r], r.x) |> plan() |> all()
@@ -887,21 +871,6 @@ defmodule Ecto.Adapters.TdsTest do
887871

888872
query = Schema |> group_by([r], []) |> select([r], r.x) |> plan()
889873
assert all(query) == ~s{SELECT s0.[x] FROM [schema] AS s0}
890-
891-
query =
892-
from(row in Schema, as: :r, select: row.x)
893-
|> group_by(
894-
[r],
895-
exists(
896-
from other_schema in "schema",
897-
where: other_schema.x == parent_as(:r).x,
898-
select: [other_schema.x]
899-
)
900-
)
901-
|> plan()
902-
903-
assert all(query) ==
904-
~s{SELECT s0.[x] FROM [schema] AS s0 GROUP BY exists(SELECT ss0.[x] AS [result] FROM [schema] AS ss0 WHERE (ss0.[x] = s0.[x]))}
905874
end
906875

907876
test "interpolated values" do

0 commit comments

Comments
 (0)