Skip to content

Commit

Permalink
Raise on unsupported exprs (#362)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
v0idpwn committed Nov 30, 2021
1 parent fb72dc8 commit 93038c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/ecto/adapters/myxql/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,10 @@ if Code.ensure_loaded?(MyXQL) do
["(0 + ", Float.to_string(literal), ?)]
end

defp expr(expr, _sources, query) do
error!(query, "unsupported expression: #{inspect(expr)}")
end

defp interval(count, "millisecond", sources, query) do
["INTERVAL (", expr(count, sources, query) | " * 1000) microsecond"]
end
Expand Down
4 changes: 4 additions & 0 deletions lib/ecto/adapters/postgres/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,10 @@ if Code.ensure_loaded?(Postgrex) do
[Float.to_string(literal) | "::float"]
end

defp expr(expr, _sources, query) do
error!(query, "unsupported expression: #{inspect(expr)}")
end

defp type_unless_typed(%Ecto.Query.Tagged{}, _type), do: []
defp type_unless_typed(_, type), do: [?:, ?: | type]

Expand Down

0 comments on commit 93038c2

Please sign in to comment.