Replies: 1 comment
-
To verify something simpler, I tried to verify if Custom Struct can define fields for a simple model of my own making instead of the sea-orm model. I understood that to use #[derive(Clone, Debug, PartialEq, Eq, DeriveValueType)]
pub struct Hoge(pub String);
#[derive(Debug, FromQueryResult)]
struct SelectResult {
id: i32,
hoge: Hoge,
} Therefore, the above implementation could be built. However, if the #[derive(Clone, Debug, PartialEq, Eq, DeriveValueType)]
pub struct Hoge {
pub huga: String,
}
// #[derive(Clone, Debug, PartialEq, Eq, DeriveValueType)]
// pub struct Hoge(pub String);
#[derive(Debug, FromQueryResult)]
struct SelectResult {
id: i32,
hoge: Hoge,
}
Apparently, |
Beta Was this translation helpful? Give feedback.
-
I want to implement the question asked in #1028 . There it is suggested that using a
Custom Struct
, so I am implementing that.The implementation is based on the examples using
Custom Struct
below.https://github.com/SeaQL/sea-orm/blob/master/examples/basic/src/select.rs#L152
I believe that if
SelectResult
can be defined as above, the select result is easy to use. However, writing theSelectResult
in this manner results in the following build error.I honestly don't understand this error exactly, but I am guessing that if adding a non-primitive type to a field in a
Custom Struct
, it cannot be converted byFromQueryResult
. In this case, would it be possible to define a field of a non-primitive type in theCustom Struct
by implementingTryGetable
on thecake::Model
orVec<fruit::Model>
defined below?https://github.com/SeaQL/sea-orm/blob/master/examples/basic/src/example_cake.rs
https://github.com/SeaQL/sea-orm/blob/master/examples/basic/src/example_fruit.rs
Beta Was this translation helpful? Give feedback.
All reactions