Skip to content

Commit 295a2a4

Browse files
committed
Remove JSON format as to not directly depend on Jason
1 parent 051baf6 commit 295a2a4

3 files changed

Lines changed: 3 additions & 16 deletions

File tree

integration_test/pg/explain_test.exs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ defmodule Ecto.Integration.ExplainTest do
2727
end)
2828
end
2929

30-
test "explain JSON format" do
31-
[explain] = TestRepo.explain(:all, Post, analyze: true, verbose: true, timeout: 20000, format: :json) |> Jason.decode!()
32-
keys = explain["Plan"] |> Map.keys
33-
assert Enum.member?(keys, "Actual Loops")
34-
assert Enum.member?(keys, "Actual Rows")
35-
assert Enum.member?(keys, "Actual Startup Time")
36-
end
37-
3830
test "explain MAP format" do
3931
[explain] = TestRepo.explain(:all, Post, analyze: true, verbose: true, timeout: 20000, format: :map)
4032
keys = explain["Plan"] |> Map.keys

lib/ecto/adapters/postgres/connection.ex

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,9 @@ if Code.ensure_loaded?(Postgrex) do
255255
{explain_opts, opts} =
256256
Keyword.split(opts, ~w[analyze verbose costs settings buffers timing summary format]a)
257257

258-
json_format? = {:format, :json} in explain_opts
259258
map_format? = {:format, :map} in explain_opts
260259

261260
case query(conn, build_explain_query(query, explain_opts), params, opts) do
262-
{:ok, %Postgrex.Result{rows: rows}} when json_format? ->
263-
case Jason.encode(List.flatten(rows)) do
264-
{:ok, json} -> {:ok, json}
265-
{:error, error} -> error
266-
end
267261
{:ok, %Postgrex.Result{rows: rows}} when map_format? ->
268262
{:ok, List.flatten(rows)}
269263
{:ok, %Postgrex.Result{rows: rows}} ->
@@ -1244,7 +1238,6 @@ if Code.ensure_loaded?(Postgrex) do
12441238
defp quote_boolean(value), do: error!(nil, "bad boolean value #{value}")
12451239

12461240
defp format_to_sql(:text), do: "FORMAT TEXT"
1247-
defp format_to_sql(:json), do: "FORMAT JSON"
12481241
defp format_to_sql(:map), do: "FORMAT JSON"
12491242
defp format_to_sql(:yaml), do: "FORMAT YAML"
12501243

lib/ecto/adapters/sql.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,9 @@ defmodule Ecto.Adapters.SQL do
281281
282282
Also note that:
283283
284-
* Currently `:json`, `:map`, `:yaml` and `:text` format options are supported for PostgreSQL
284+
* Currently `:map`, `:yaml`, and `:text` format options are supported
285+
for PostgreSQL. `:map` is the deserialized JSON encoding. The last two
286+
options return the result as a string.
285287
* Any other value passed to `opts` will be forwarded to the underlying
286288
adapter query function, including Repo shared options such as `:timeout`;
287289
* Non built-in adapters may have specific behavior and you should consult

0 commit comments

Comments
 (0)