diff --git a/lib/ecto/adapters/myxql/connection.ex b/lib/ecto/adapters/myxql/connection.ex index f5a36695..aa7f4199 100644 --- a/lib/ecto/adapters/myxql/connection.ex +++ b/lib/ecto/adapters/myxql/connection.ex @@ -347,7 +347,7 @@ if Code.ensure_loaded?(MyXQL) do defp distinct(%ByExpr{expr: false}, _sources, _query), do: [] defp distinct(%ByExpr{expr: exprs}, _sources, query) when is_list(exprs) do - error!(query, "DISTINCT with multiple columns is not supported by MySQL") + error!(query, "to apply DISTINCT to multiple columns in MySQL, use distinct: true") end defp select([], _sources, _query), diff --git a/test/ecto/adapters/myxql_test.exs b/test/ecto/adapters/myxql_test.exs index 43576b7c..e33bff6a 100644 --- a/test/ecto/adapters/myxql_test.exs +++ b/test/ecto/adapters/myxql_test.exs @@ -385,7 +385,7 @@ defmodule Ecto.Adapters.MyXQLTest do assert all(query) == ~s{SELECT s0.`x`, s0.`y` FROM `schema` AS s0} assert_raise Ecto.QueryError, - ~r"DISTINCT with multiple columns is not supported by MySQL", + ~r"to apply DISTINCT to multiple columns in MySQL, use distinct: true", fn -> query = Schema |> distinct([r], [r.x, r.y]) |> select([r], {r.x, r.y}) |> plan() @@ -394,7 +394,7 @@ defmodule Ecto.Adapters.MyXQLTest do end assert_raise Ecto.QueryError, - ~r"DISTINCT with multiple columns is not supported by MySQL", + ~r"to apply DISTINCT to multiple columns in MySQL, use distinct: true", fn -> query = from(row in Schema, as: :r, select: row.x)