Я пытаюсь запросить массив json в таблице building
, столбце jsonb metadata
и в свойстве google_place_ids
, которое является массивом.
Эликсир выдает мне ошибку:
Вот запрос, который генерирует фрагмент:
SELECT b0."id", b0."base_sku", b0."name", b0."logo", b0."email", b0."active", b0."sync", b0."building_group_id", b0."operating_region_id", b0."building_package_id", b0."metadata", b0."location", b0."inserted_at", b0."updated_at" FROM "buildings" AS b0 WHERE (b0."metadata"->'google_place_ids' @> '["$1"]') AND (b0."active" = TRUE) ["1234231223123"]
Вот код:
defp query_by_google_place_id(query, google_place_id) do
from(b in query,
where: fragment("?->'google_place_ids' @> '[\"?\"]'", b.metadata, ^google_place_id),
where: b.active == true,
limit: 1)
end
Вот ошибка:
[error] #PID<0.1340.0> running Proxy.InstrumentedPlug terminated
Server: localhost:4000 (http)
Request: GET /something/google_place_id/1234231223123
** (exit) an exception was raised:
** (ArgumentError) parameters must be of length 0 for query %Postgrex.Query{columns: