-
Hello, I have a table like this: CREATE TABLE posts (
title TEXT PRIMARY KEY,
created TIMESTAMP WITH TIMEZONE NOT NULL,
modified TIMESTAMP WITH TIMEZONE NOT NULL
) I have this struct: #[derive(Debug, Queryable, Insertable)]
struct Post {
title: String,
created: DateTime<Utc>,
modified: DateTime<Utc>
} I would like to upsert many posts at once, updating a row only if the diesel::insert_into(posts)
.values(new_posts)
.on_conflict(title)
.filter_target(modified.lt(excluded(modified)))
.do_update()
.set((
created.eq(excluded(created)),
modified.eq(excluded(modified)),
))
.execute(&mut conn) But this returns the following error:
Any suggestions? |
Beta Was this translation helpful? Give feedback.
Answered by
weiznich
Apr 14, 2023
Replies: 1 comment 3 replies
-
There are multiple points to address in this question:
|
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
deved99
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are multiple points to address in this question:
ON CONFLICT
target, but you want to apply the filter to the update part. That's #3330, which is currently only implemented on diesels master branch.