test: one-to-many relationships work

This commit is contained in:
2025-01-31 22:22:06 +01:00
parent bca0619f30
commit 86e29fa2dc
2 changed files with 8 additions and 2 deletions

View File

@@ -31,7 +31,12 @@ impl Ord for Author {
}
#[derive(Debug, sqlx::FromRow, Georm, PartialEq, Eq, Default)]
#[georm(table = "books")]
#[georm(
table = "books",
one_to_many = [
{ name = "reviews", remote_id = "book_id", table = "reviews", entity = Review }
]
)]
pub struct Book {
#[georm(id)]
ident: i32,
@@ -59,5 +64,5 @@ pub struct Review {
pub id: i32,
#[georm(relation = {entity = Book, table = "books", remote_id = "ident", name = "book"})]
pub book_id: i32,
pub review: String
pub review: String,
}