Use #[diesel::dsl::auto_type]
in some places
#8970
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit replaces some of the manual written type aliases by
#[diesel::dsl::auto_type]
which just generates the correct return type based on the function content. This hopefully removes some complexity from the database code.The main motivation for this change is to update the diesel Composing Applications guide which is based on this code.
I'm not 100% happy with this as it's currently not possible to use
#[auto_type]
for all the the type defs due to the following reasons:#[auto_type]
by default generates a type def alongside the function that names the return type. This cannot easily be done here as associated types for non-trait impls are not stable yet. (That's the reason for theno_type_alias
option)