Minor cleanup on dependency insertion and loading #1213
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.
I'm going through some random code as I'm looking to point to this repo
more in Diesel's guides for some actual examples. My goal was actually
to do the following:
#[derive(Insertable)]
onupload::CrateDependency
and use thatdirectly
#[derive(Queryable)]
ongit::Dependency
and construct it from areturning clause
However, doing the first piece would require skipping the
crate_name
field or pulling it out of that struct, and the second piece requires
some way to tell Diesel that a subselect returns a single row (which is
not hard to do, but is not code that should live in this repo)
Either way, while I was experimenting I did a bit of cleanup here which
I think is worthwhile on its own.
Insertable
struct in favor of tuple inserts, sinceInsertable
is really only mean to be used when your input comes fromanother source (like
Deserialize
).default impl that was only used in tests. I thought about pushing
these defaults into the database, but that felt sketchy for the same
reason
vec.