Can Selectable generate a dynamic SelectExpression?
#4801
Replies: 2 comments 1 reply
-
|
It is certainly possible to return a "dynamic" value from the selectable trait. The same rules as everywhere in diesel apply here as well, you would need to use something like Now to the actual problem that you will face there: |
Beta Was this translation helpful? Give feedback.
-
|
The goal is to be able to have a selection configuration that is a simple JSON-mappable struct like: and then to select these fields from the underlying table and return a struct like: I've been trying to do what I think you're suggesting with various incantations along these lines: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Backend
PostgreSQL
Diesel version
2.3.2
Diesel Features
postgres
Operating System Version
No response
Third party libraries
No response
What do you want to do?
Trait
Selectableallows generating a select expression from a struct. Is it possible to make the select expression dynamic at runtime?To tweak the example in the docs, I'd like to do something like:
This clearly doesn't work, not least of which:
Alternatively, can this be accomplished by stuffing the select with
nullvalues somehow?Compile time error
No response
What code do you already have?
No response
Additional details
No response
Checklist
Beta Was this translation helpful? Give feedback.
All reactions