Fix one-to-many relationship for SQLite and MySQL
Opened this issue · 1 comments
mjovanc commented
We need to be able to fix the possibility of storing a vector of structs that derive the Table
procedural macro:
#[derive(Table)]
#[table_name = "orders"]
pub struct Order {
id: usize,
user: User, // one-to-one relationship
products: Vec<Product>, // one-to-many relationship - populates from based on junction table (gets from macro attribute "table_name" and combines them for example, orders_products)
total_cost: f64,
}
As you can see here when we define a field called products
and add a vector of Product
. It will complain about:
- doesn't satisfy `syn::Type: ToString` or `syn::Type: std::fmt::Display`
We need to be able to support this in the njord_derive library.
mjovanc commented
@chaseWillden Do you have any idea how we can solve this if we haven't already?