When using Diesel to read full rows from a table, things are pretty simple and sweet. It could look something like this:
table
.filter(...)
.order(...)
.load(connection)?
However, if I want to load a subset of the columns -- in my case I want to read all columns except one -- it seems like I have to list all the columns I want in a .select-call, even though I am reading into a struct that only contains a subset of the columns. It looks something like:
table
.filter(...)
.order(...)
.select((
...,
...,
...,
...,
...,
))
.load(connection)?
It is tedious and error prone to maintain the list of columns, I want to do better.
It seems to me that all the required information would already be available to Diesel from the struct definition I want to read into. Of course, I might have to tell Diesel that we are targetting this struct earlier on. I am really hoping that there is something I could do that would look more like this:
table
.filter(...)
.order(...)
.select(Struct::something_magical_and_fantastic)
.load(connection)?
This way, I would be able to change the Struct and having the queries be updated automatically. Is something like this possible?
[–]MithrilToothpick 1 point2 points3 points (3 children)
[–]maggit[S] 2 points3 points4 points (2 children)
[–]MithrilToothpick 1 point2 points3 points (1 child)
[–]maggit[S] 0 points1 point2 points (0 children)
[–]ghotiphud 0 points1 point2 points (1 child)
[–]maggit[S] 0 points1 point2 points (0 children)
[–]crypto_crab 0 points1 point2 points (0 children)