Skip to content

optimistic locking #4595

Answered by weiznich
zoechi asked this question in Q&A
May 9, 2025 · 2 comments · 2 replies
Discussion options

You must be logged in to vote

The query written there should work as written assuming the type mappings are correct.

As for the additional check: There is the OptionalExtension::optional() which turns a NotFound error into a Option<T>. That's likely the thing you want to use there.

Otherwise there is no additional support for this in diesel. I also do not see why this should be something that's "directly" supported as there are just to many variables there (name of the version column, etc). You still would need to specify essentially the same information there instead of in the update statement, so this wouldn't become easier.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@weiznich
Comment options

Answer selected by zoechi
@zoechi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants