Skip to content

Commit aa2d65f

Browse files
authored
Merge pull request rails#49730 from muxinqi/fix-docs
Fix factually incorrect SQL statements [ci skip]
2 parents 4f42b31 + 6dd1f87 commit aa2d65f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

guides/source/active_record_querying.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,7 @@ The above code will execute just **2** queries, as opposed to the **11** queries
16401640
```sql
16411641
SELECT books.* FROM books LIMIT 10
16421642
SELECT authors.* FROM authors
1643-
WHERE authors.book_id IN (1,2,3,4,5,6,7,8,9,10)
1643+
WHERE authors.id IN (1,2,3,4,5,6,7,8,9,10)
16441644
```
16451645

16461646
#### Eager Loading Multiple Associations
@@ -1717,7 +1717,7 @@ The above code will execute just **2** queries, as opposed to the **11** queries
17171717
```sql
17181718
SELECT books.* FROM books LIMIT 10
17191719
SELECT authors.* FROM authors
1720-
WHERE authors.book_id IN (1,2,3,4,5,6,7,8,9,10)
1720+
WHERE authors.id IN (1,2,3,4,5,6,7,8,9,10)
17211721
```
17221722

17231723
NOTE: The `preload` 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. However, unlike the `includes` method, it is not possible to specify conditions for preloaded associations.
@@ -1739,9 +1739,9 @@ end
17391739
The above code will execute just **2** queries, as opposed to the **11** queries from the original case:
17401740

17411741
```sql
1742-
SELECT DISTINCT books.id FROM books LEFT OUTER JOIN authors ON authors.book_id = books.id LIMIT 10
1742+
SELECT DISTINCT books.id FROM books LEFT OUTER JOIN authors ON authors.id = books.author_id LIMIT 10
17431743
SELECT books.id AS t0_r0, books.last_name AS t0_r1, ...
1744-
FROM books LEFT OUTER JOIN authors ON authors.book_id = books.id
1744+
FROM books LEFT OUTER JOIN authors ON authors.id = books.author_id
17451745
WHERE books.id IN (1,2,3,4,5,6,7,8,9,10)
17461746
```
17471747

0 commit comments

Comments
 (0)