diff --git a/tests/fixtures/o2o.sql b/tests/fixtures/o2o.sql index 9ac8534..7b43179 100644 --- a/tests/fixtures/o2o.sql +++ b/tests/fixtures/o2o.sql @@ -7,4 +7,5 @@ VALUES ('The Lord of the Rings: The Fellowship of the Ring', 1), INSERT INTO reviews (book_id, review) VALUES (1, 'Great book'), (3, 'Awesome book'), + (2, 'Probably his best work!'), (2, 'Greatest book'); diff --git a/tests/models.rs b/tests/models.rs index bef3224..ad45b07 100644 --- a/tests/models.rs +++ b/tests/models.rs @@ -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, }