Insert_all not respecting :id

I’m passing a list of maps and I’m trying to run them through a insert_all in Ecto.multi:

  def create_jobs(%{jobs: jobs} = attrs) do
    insert_jobs =
      Ecto.Multi.new()
      |> Ecto.Multi.insert_all(:jobs, Job, jobs)
      |> Repo.transaction()

When I try and save this, I get:
value"3310"forTalent.JobManagement.Schemas.Job.owner_idininsert_alldoes not match type :id

I thought strings were valid as an :id.

The model for Job has:

belongs_to(:owner, User)

Any ideas?

You seem to be supplying a string for the id when it should be an integer. So a job map should not have %{id: "3310"} and instead it should have %{id: 3310}.

1 Like