Skip to content

Commit 6935c28

Browse files
committed
Improve json interpolation exception message
1 parent 96f70b5 commit 6935c28

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

integration_test/pg/exceptions_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defmodule Ecto.Integration.ExceptionsTest do
77

88
test "on bad JSON interpolation" do
99
assert_raise Postgrex.Error,
10-
~r/If you are trying to query a JSON field, the parameter must be interpolated/,
11-
fn -> TestRepo.all(from p in Post, where: p.meta["field"] == "example") end
10+
~r/If you are trying to query a JSON field, the parameter may need to be interpolated/,
11+
fn -> TestRepo.all(from p in Post, where: p.meta["field"] != "example") end
1212
end
1313
end

lib/ecto/adapters/postgres/connection.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ if Code.ensure_loaded?(Postgrex) do
7373
. If you are trying to query a JSON field, the parameter may need to be interpolated. \
7474
Instead of
7575
76-
p.json["field"] == "value"
76+
p.json["field"] != "value"
7777
7878
do
7979
80-
p.json["field"] == ^"value"
80+
p.json["field"] != ^"value"
8181
"""
8282

8383
{:error, put_in(error.postgres.message, message <> context)}

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"decimal": {:hex, :decimal, "1.9.0", "83e8daf59631d632b171faabafb4a9f4242c514b0a06ba3df493951c08f64d07", [:mix], [], "hexpm", "b1f2343568eed6928f3e751cf2dffde95bfaa19dd95d09e8a9ea92ccfd6f7d85"},
77
"deep_merge": {:hex, :deep_merge, "0.2.0", "c1050fa2edf4848b9f556fba1b75afc66608a4219659e3311d9c9427b5b680b3", [:mix], [], "hexpm", "e3bf435a54ed27b0ba3a01eb117ae017988804e136edcbe8a6a14c310daa966e"},
88
"earmark_parser": {:hex, :earmark_parser, "1.4.19", "de0d033d5ff9fc396a24eadc2fcf2afa3d120841eb3f1004d138cbf9273210e8", [:mix], [], "hexpm", "527ab6630b5c75c3a3960b75844c314ec305c76d9899bb30f71cb85952a9dc45"},
9-
"ecto": {:git, "https://github.com/elixir-ecto/ecto.git", "5b2abf83cb730d29c10a1bb3522226caadd6d1b6", []},
9+
"ecto": {:git, "https://github.com/elixir-ecto/ecto.git", "2a6bc237af300cc8698dfe2121aa49dedc5ecd2a", []},
1010
"ex_doc": {:hex, :ex_doc, "0.27.3", "d09ed7ab590b71123959d9017f6715b54a448d76b43cf909eb0b2e5a78a977b2", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "ee60b329d08195039bfeb25231a208749be4f2274eae42ce38f9be0538a2f2e6"},
1111
"jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"},
1212
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},

0 commit comments

Comments
 (0)