Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Mongo.insert_many does not continue_on_error when it encounters a Mongo.WriteError #346

Description

@toddholmberg

Hello. I am getting a Mongo.WriteError when using Mongo.insert_many/4 with [continue_on_error: true]. I am setting the _id field, so can expect a duplicate key error once in a while. I assumed that continue_on_error would proceed in face of write errors. This is mentioned in an elixirforum post: https://elixirforum.com/t/understanding-dialyzer-error-the-pattern-can-never-match-the-type/31553

In the post it is suggested that Mongo.WriteError be added as an additional return type.

@type result(t) :: :ok | {:ok, t} | {:error, Mongo.Error.t()}

should be (I think) something like:

@type result(t) :: :ok | {:ok, t} | {:error, Mongo.Error.t()} | {:error, Mongo.WriteError.t()}

In the end, I just want insert_many to continue inserting the remaining items when it encounters write errors. Is this a possible change?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions