Closed almozavr closed 6 years ago
Multi.new() |> Multi.run(:userchat, fn _ -> userchat = Chat |> join(:inner, [c], uc in UserChat, uc.chat_id == c.id and uc.user_id == ^user_id) |> where([c], c.uid == ^chat_uid) |> select([c, uc], uc) |> Repo.one() Message |> where([m], (is_nil(^userchat.read_message_at)) and m.inserted_at < ^read_at_date) |> Repo.update_all(set: [status: :read]) userchat |> Ecto.Changeset.change(read_message_at: read_at_date) |> Repo.update() {:ok, userchat} end) |> Repo.transaction()
Postgrex.Error) ERROR 42P18 (indeterminate_datatype): could not determine data type of parameter $2 (ecto) lib/ecto/adapters/sql.ex:431: Ecto.Adapters.SQL.execute_and_cache/7 (treel_chat) lib/app_chat/services/chat_service.ex:81: anonymous fn/2 in AppChat.ChatService.mark_as_read/3 (ecto) lib/ecto/multi.ex:421: Ecto.Multi.apply_operation/5 (elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3 (ecto) lib/ecto/multi.ex:411: anonymous fn/5 in Ecto.Multi.apply_operations/5 (ecto) lib/ecto/adapters/sql.ex:576: anonymous fn/3 in Ecto.Adapters.SQL.do_transaction/3 (db_connection) lib/db_connection.ex:1283: DBConnection.transaction_run/4 (db_connection) lib/db_connection.ex:1207: DBConnection.run_begin/3 (db_connection) lib/db_connection.ex:798: DBConnection.transaction/3 (ecto) lib/ecto/repo/queryable.ex:23: Ecto.Repo.Queryable.transaction/4
Same code without Multi works fine.
Multi
Sorry, the issue is elsewhere but enum.
Code Sample
Issue
Same code without
Multi
works fine.