Using Repo.insert_or_update without a changeset

The Ecto documentation clearly states that I can pass a struct_or_changeset to the insert_or_update/2 function on Repo

When I do this I get an error that says “giving a struct to Repo.insert_or_update/2 or Repo.insert_or_update!/2 is not supported”. When I use just insert/2 I can directly pass a struct.

Is it no longer possible to use this function without a changeset?

I have tried my code with versions 2.1.1 and 2.1.4 of ecto.


@Crowdhailer: I created github issue.

Thanks, do you know if there is anyway to just overwrite DB entries. That is what I am looking to achieve. The logic I have does not rely on changesets

@Crowdhailer: you need a changeset for safe way to update, but you can also use: &Ecto.Query.update/3 if you really do not want to use changeset.

What do you mean by “safe”. What extra guarantees are you getting?

@Crowdhailer: casting and validating - especially when you receive data from user or if source data have edge cases
You can see it when scraping data from lots of sites. Generally you expect that thousands of info pages have all info that you require, but for example some data could be missing (just not entered by user/admin).