1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-08 17:48:01 +00:00

Add a caveat to the latest TIL

This commit is contained in:
jbranchaud
2024-11-13 20:31:25 -06:00
parent 484dec8e24
commit 74514b462d

View File

@@ -41,3 +41,9 @@ the query. And the `#take` corresponds to the `limit 1`.
Knowing that, we can understand that we will also get the first record from the Knowing that, we can understand that we will also get the first record from the
database if we call `#find_by` with `{}`. Again, no conditions to filter on, so database if we call `#find_by` with `{}`. Again, no conditions to filter on, so
give me all books limited to one. give me all books limited to one.
One small caveat: notice how there is no `order by` clause in the above SQL
output. This differs from `Books.first` which implicitly does an order on the
`id` column. Though these method are likely to return the same result, the
ordering of `#find_by` is not guaranteed to be the same without an `order by`
clause.