privalou
privalou

Reputation: 60

How do I upsert in sqlite using diesel?

I am migrating rust application from Postgres to Sqlite. But I've got an issue with upsert

Following code

diesel::insert_into(dialogs_table)
            .values(dialog)
            .on_conflict(user_id_column)

gives me this:

error[E0599]: no method named `on_conflict` found for struct InsertStatement in the current scope

I find this strange because it was working for Postgres. What could be the possible solution to use upsert here?

Upvotes: 0

Views: 1036

Answers (1)

Masklinn
Masklinn

Reputation: 42492

What could be the possible solution to use upsert here?

Support for sqlite upserts was merged in early 2020 (after a very long and rather gruelling PR process), but it apparently includes breaking changes so my understanding's it'll only be available in Diesel 2.0.

Therefore your possibly solutions are:

  1. don't use upserts

  2. perform your query by hand

  3. use git diesel

Upvotes: 3

Related Questions