Skip to content

Commit 93038c2

Browse files
authored
Raise on unsupported exprs (#362)
Instead of the unfriendly "no case clause matching", this raises an error telling the user that the literal is not supported. This was already done by tds adapter.
1 parent fb72dc8 commit 93038c2

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/ecto/adapters/myxql/connection.ex

+4
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,10 @@ if Code.ensure_loaded?(MyXQL) do
657657
["(0 + ", Float.to_string(literal), ?)]
658658
end
659659

660+
defp expr(expr, _sources, query) do
661+
error!(query, "unsupported expression: #{inspect(expr)}")
662+
end
663+
660664
defp interval(count, "millisecond", sources, query) do
661665
["INTERVAL (", expr(count, sources, query) | " * 1000) microsecond"]
662666
end

lib/ecto/adapters/postgres/connection.ex

+4
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,10 @@ if Code.ensure_loaded?(Postgrex) do
745745
[Float.to_string(literal) | "::float"]
746746
end
747747

748+
defp expr(expr, _sources, query) do
749+
error!(query, "unsupported expression: #{inspect(expr)}")
750+
end
751+
748752
defp type_unless_typed(%Ecto.Query.Tagged{}, _type), do: []
749753
defp type_unless_typed(_, type), do: [?:, ?: | type]
750754

0 commit comments

Comments
 (0)