Skip to content

Fix one-to-many relationship for SQLite and MySQL #53

@mjovanc

Description

@mjovanc

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or requestmysqlsqliteIssues related to SQLite

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions