Make empty changeset updates using .optional()
, either ignore or bypass errors QueryBuilderError
s.
#4018
dessalines
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
@dessalines I've converted this to a discussion as this is strictly speaking a new feature. The |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Setup
Versions
Feature Flags
Problem Description
Oftentimes, when doing DB updates, we need to build changeset objects, where we don't know beforehand if its an empty changeset, IE if all the updated fields are
None
.When that's the case, diesel throws a runtime QueryBuilderError, which needs to be explicitly caught.
We'd like to either ignore, or bypass that error completely, rather than having to catch runtime QueryBuilderError s for every single update in our application.
The best solution IMO, would be to add this functionality to the existing
.optional()
, which already does a similar function: turning emptyget_result
from an error to an option.Adding this would also turn an empty update / changeset into an Option. IE, if
.optional()
is done, convert a QueryBuilderError intoNone
, rather than throwing a runtime error.Context: LemmyNet/lemmy#4705
Also #598 , #1996
Checklist
closed if this is not the case)
Beta Was this translation helpful? Give feedback.
All reactions