Replies: 2 comments 4 replies
-
I converted this to a discussion as this is not an issue in diesel but a support question. Please do not fill such questions as bug reports. I will just close the next one as invalid, instead of converting them. To the actual question: I will try to write an answer later |
Beta Was this translation helpful? Give feedback.
-
For reference the provided example fails to compile with the following error message:
That's expected as there is no For insertion it's possible to ignore it via #[diesel(skip_insertion)] For selection it's possible to select a dummy value instead via #[diesel(select_expression = None::<String>.into_sql::<Nullable<Text>>())]
#[diesel(select_expression_type = diesel::dsl::IntoSql<Option<String>, Nullable<Text>>)] More generally speaking: It's usually preferred to just split the structs if you don't need all fields in all cases, that's much better than working with configs or fake values. |
Beta Was this translation helpful? Give feedback.
-
Setup
Versions
Feature Flags
Problem Description
What are you trying to accomplish?
It is kind of related to #860, but not at the same level.
We have an API that uses the same structure to insert, update, delete or select. We usually need to return all fields of the table. That work well. But we have a model (and maybe more later) that uses features to not use certain fields.
We return the model in all cases.
We use a trait to implement functions like insert, select, update and delete on the model.
But the trait seems unable to compile. But when the function is in an implementation, it compiles.
Is there some best advice to deal with features in the structures?
Or if there isn't, is there something wrong with the way we do our traits? Is there an obvious missing trait?
What is the expected output?
Compiling using a trait.
What is the actual output?
Our trait don't compile because of impossible requirements, for example, SingleValue to return several fields.
Are you seeing any additional errors?
Steps to reproduce
See https://gist.github.com/NoemieTav/bce7a200fa07b8ee39810fa13b09290f for example.
The trait is commented,
Checklist
closed if this is not the case)
Beta Was this translation helpful? Give feedback.
All reactions