Support Default value for unselected columns #1507
Reverier-Xu
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
|
Hi, maybe we can provide a macro like this: #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "cake")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub name: String,
#[sea_orm(allow_missing)] // <- allow the default value to be filled when a `ColumnNotFound` error occurs in `sqlx::*Row::try_get`
pub taste_description: String,
}and then modify the error handling in This solution doesn't look clean, but if it's okay, I'll work on it. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Motivation
I have read your document CustomSelect and some issues (#302), it seems that if I want to select only some of the fields, I have to define a corresponding Lite Struct to receive the data returned by Sea Orm. This can be troublesome in some cases, for example, in a User table with many information fields, I only want to hide the password field, in order to filter out this field I need to define two very large Model structs, the difference between them is only that one of them does not have the password field.
Proposed Solutions
Is it possible to have the unselected fields automatically populated with
Default::default()or some other default value implementation?Current Workarounds
none.
Beta Was this translation helpful? Give feedback.
All reactions