Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly update cluster read model with and empty check selection #426

Open
nelsonkopliku opened this issue Apr 26, 2022 · 0 comments
Open

Comments

@nelsonkopliku
Copy link
Member

The's some issue when saving an empty checks selection.

This code does not correctly update

changeset =
        %ClusterReadModel{id: id}
        |> ClusterReadModel.changeset(%{
          selected_checks: checks
        })
Ecto.Multi.update(multi, :cluster, changeset)

The following code works but it might be subject to race conditions.

See 55c52e3

changeset =
        ClusterReadModel
        |> Repo.get(id)
        # TODO: couldn't make it work with Ecto.Multi
        # With following line when we receive an empty list of selected checks, the readmodel does not get updated
        # %ClusterReadModel{id: id}
        |> ClusterReadModel.changeset(%{
          selected_checks: checks
        })
Ecto.Multi.update(multi, :cluster, changeset)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant