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

Crash with duplicate insertion and ON CONFLICT DO NOTHING with Postgres. #1175

Closed
baszalmstra opened this issue Oct 31, 2022 · 1 comment
Closed

Comments

@baszalmstra
Copy link

Description

When inserting an entry in Postgres with an ON CONFLICT DO NOTHING twice the exec_insert method fails.

Steps to Reproduce

Running the following query twice with the same value will yield no return result in the second run:

INSERT INTO
          "url" ("url")
        VALUES
          ($1) ON CONFLICT ("url") DO NOTHING RETURNING "id"

However, the function exec_insert expects a return value to exist on line 119 of src/executor/insert.rs. When running the query twice the program will crash with:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', C:\Users\me\.cargo\registry\src\github.aaakk.us.kg-1ecc6299db9ec823\sea-orm-0.10.1\src\executor\insert.rs:119:54

The sea-orm code that was used is:

url::Entity::insert_many(insertable_urls.clone())
        .on_conflict(OnConflict::column(url::Column::Url).do_nothing().to_owned())
        .exec(db)
        .await;

Expected Behavior

I expect this query to work fine.

Actual Behavior

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', C:\Users\me\.cargo\registry\src\github.aaakk.us.kg-1ecc6299db9ec823\sea-orm-0.10.1\src\executor\insert.rs:119:54

Reproduces How Often

Every time

Versions

sea-orm 0.10.1

(Note that the above shortcut to past in the console doesn't work in powershell)

@billy1624
Copy link
Member

Hey @baszalmstra, thanks for the report!! I think this issue is a duplicate of

I'll look at both issue together. Thanks!!

@billy1624 billy1624 moved this to Triage in SeaQL Dev Tracker Nov 4, 2022
@billy1624 billy1624 moved this from Triage to Done in SeaQL Dev Tracker Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants