Open imraan-go opened 2 years ago
So here is the scenario, I want to select 2 items from each order on the following example: https://bun.uptrace.dev/guide/relations.html#many-to-many-relation
orders := []Order{} db.NewSelect().Model(&orders).Relation("Items", func(q *bun.SelectQuery) *bun.SelectQuery { return q.Limit(2) }).Scan(ctx)
The following query only selects first 2 items instead of selecting 2 items per product.
This is a limitation of the current m2m query generator. Perhaps we should check if limit != 0 and issue a separate query for each order.
limit != 0
So here is the scenario, I want to select 2 items from each order on the following example: https://bun.uptrace.dev/guide/relations.html#many-to-many-relation
The following query only selects first 2 items instead of selecting 2 items per product.