diff --git a/integration_test/sql/subquery.exs b/integration_test/sql/subquery.exs index 79c90fa7..d820924b 100644 --- a/integration_test/sql/subquery.exs +++ b/integration_test/sql/subquery.exs @@ -113,6 +113,7 @@ defmodule Ecto.Integration.SubQueryTest do assert [12, 12] = TestRepo.all(query) end + @tag :subquery_in_order_by test "subqueries in order by" do TestRepo.insert!(%Post{visits: 10, title: "hello"}) TestRepo.insert!(%Post{visits: 11, title: "hello"}) @@ -123,6 +124,7 @@ defmodule Ecto.Integration.SubQueryTest do end @tag :multicolumn_distinct + @tag :subquery_in_distinct test "subqueries in distinct" do TestRepo.insert!(%Post{visits: 10, title: "hello1"}) TestRepo.insert!(%Post{visits: 10, title: "hello2"}) @@ -133,6 +135,7 @@ defmodule Ecto.Integration.SubQueryTest do assert [%{title: "hello"}, %{title: "hello1"}] = TestRepo.all(query) end + @tag :subquery_in_group_by test "subqueries in group by" do TestRepo.insert!(%Post{visits: 10, title: "hello1"}) TestRepo.insert!(%Post{visits: 10, title: "hello2"}) diff --git a/integration_test/tds/test_helper.exs b/integration_test/tds/test_helper.exs index d8747c50..9e0788b6 100644 --- a/integration_test/tds/test_helper.exs +++ b/integration_test/tds/test_helper.exs @@ -58,8 +58,12 @@ ExUnit.start( :selected_as_with_order_by_expression, # MSSQL doesn't support specifying columns for ON DELETE SET NULL :on_delete_nilify_column_list, - # MySQL doesnt' support anything except a single column in DISTINCT - :multicolumn_distinct + # MSSQL doesnt' support anything except a single column in DISTINCT + :multicolumn_distinct, + # MSSQL doesnt' support subqueries in group by or in distinct + :subquery_in_group_by, + :subquery_in_distinct, + :subquery_in_order_by ] ) diff --git a/test/ecto/adapters/tds_test.exs b/test/ecto/adapters/tds_test.exs index bbc9a562..1b5f9ac8 100644 --- a/test/ecto/adapters/tds_test.exs +++ b/test/ecto/adapters/tds_test.exs @@ -516,22 +516,6 @@ defmodule Ecto.Adapters.TdsTest do query = Schema |> order_by([r], []) |> select([r], r.x) |> plan() assert all(query) == ~s{SELECT s0.[x] FROM [schema] AS s0} - query = - from(row in Schema, as: :r) - |> order_by( - asc: - exists( - from other_schema in "schema", - where: other_schema.x == parent_as(:r).x, - select: [other_schema.x] - ) - ) - |> select([r], r.x) - |> plan() - - assert all(query) == - ~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]))} - for dir <- [:asc_nulls_first, :asc_nulls_last, :desc_nulls_first, :desc_nulls_last] do assert_raise Ecto.QueryError, ~r"#{dir} is not supported in ORDER BY in MSSQL", fn -> Schema |> order_by([r], [{^dir, r.x}]) |> select([r], r.x) |> plan() |> all() @@ -887,21 +871,6 @@ defmodule Ecto.Adapters.TdsTest do query = Schema |> group_by([r], []) |> select([r], r.x) |> plan() assert all(query) == ~s{SELECT s0.[x] FROM [schema] AS s0} - - query = - from(row in Schema, as: :r, select: row.x) - |> group_by( - [r], - exists( - from other_schema in "schema", - where: other_schema.x == parent_as(:r).x, - select: [other_schema.x] - ) - ) - |> plan() - - assert all(query) == - ~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]))} end test "interpolated values" do