kurtbuilds / ormlite

An ORM in Rust for developers that love SQL.
https://crates.io/crates/ormlite
MIT License
216 stars 11 forks source link

correct use of "one_to_many_foreign_key" ? #25

Closed jackbackes closed 1 year ago

jackbackes commented 1 year ago

https://github.com/kurtbuilds/ormlite/blob/f0be475f0ff688e406cac039942a14bb3960bdf1/attr/src/attr.rs#L79

How do I use this? Here is my example (using v0.14.2 with sqlite feature):

#[derive(Serialize, Deserialize, Debug, Clone, Model)]
pub struct Leg {
    #[ormlite(one_to_many_foreign_key = Execution::id)]
    executions: Join<Vec<Execution>>,

Error:

proc-macro derive panicked
message: not implemented
ormlite_macro
proc_macro Model
Derive macro for #[derive(Model)] It additionally generates FromRow for the struct, since Model requires FromRow.
kurtbuilds commented 1 year ago

It probably should be removed from the struct in master, but unfortunately one_to_many joins are not supported yet, only many_to_one / one_to_one. Apologies for getting your hopes up by having it defined in the struct.

The docs in README are current in describing available functionality: https://github.com/kurtbuilds/ormlite#joins

kurtbuilds commented 1 year ago

To keep issues clean, I'm going to close this issue. The roadmap section is the best way to stay up to date on when this feature is completed.