= nv.currency
from
( values
(12, 'EURO'),
(18, 'DOLLAR'),
(13, 'Pound')
) as nv (id, currency)
where account.id = nv.id ;
Может как-то так q1 = "nv" |> with_cte("nv", as: fragment("(values (12, 13), (14, 15) as (id, count))")) |> select([nv], %{id: nv.id, count: nv.count}) q2 = from( a in "account", join: nv in subquery(q1), on: a.id == nv.id) |> select([a], [a.id]) |> update([a, nv], set: [account: nv.count]) iex(41)> Ecto.Adapters.SQL.to_sql(:update_all, PayLater.Repo, q2) {"UPDATE \"account\" AS a0 SET \"account\" = s1.\"count\" FROM (WITH \"nv\" AS (values (12, 13), (14, 15) as (id, count)) SELECT sn0.\"id\" AS \"id\", sn0.\"count\" AS \"count\" FROM \"nv\" AS sn0) AS s1 WHERE (a0.\"id\" = s1.\"id\") RETURNING a0.\"id\"", []} корректность не проверял
Обсуждают сегодня