Skip to content

Commit 4835c94

Browse files
authored
Merge pull request rails#51940 from p8/guides/fix-eager-load-examples
Fix query result of eager_load example in the guides. [ci-skip]
2 parents 02621b9 + 11b25e0 commit 4835c94

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

guides/source/active_record_querying.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,13 +1744,12 @@ books.each do |book|
17441744
end
17451745
```
17461746

1747-
The above code will execute just **2** queries, as opposed to the **11** queries from the original case:
1747+
The above code will execute just **1** query, as opposed to the **11** queries from the original case:
17481748

17491749
```sql
1750-
SELECT DISTINCT books.id FROM books LEFT OUTER JOIN authors ON authors.id = books.author_id LIMIT 10
1751-
SELECT books.id AS t0_r0, books.last_name AS t0_r1, ...
1752-
FROM books LEFT OUTER JOIN authors ON authors.id = books.author_id
1753-
WHERE books.id IN (1,2,3,4,5,6,7,8,9,10)
1750+
SELECT "books"."id" AS t0_r0, "books"."title" AS t0_r1, ... FROM "books"
1751+
LEFT OUTER JOIN "authors" ON "authors"."id" = "books"."author_id"
1752+
LIMIT 10
17541753
```
17551754

17561755
NOTE: The `eager_load` method uses an array, hash, or a nested hash of array/hash in the same way as the `includes` method to load any number of associations with a single `Model.find` call. Also, like the `includes` method, you can specify conditions for eager loaded associations.

0 commit comments

Comments
 (0)