Skip to content

Commit 27a7af8

Browse files
authored
Update README.md
* s/crazy/advanced/ to avoid ableist words * last sections didn't have titles to separate topics I have written a bit more examples of "less trivial" Arel code here, perhaps we can add some of that here: https://github.com/rstacruz/cheatsheets/pull/92/files
1 parent 5cc7e77 commit 27a7af8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ users.project(users[:age].average.as("mean_age"))
188188
# => SELECT AVG(users.age) AS mean_age FROM users
189189
```
190190

191-
### The Crazy Features
191+
### The Advanced Features
192192

193193
The examples above are fairly simple and other libraries match or come close to matching the expressiveness of Arel (e.g. `Sequel` in Ruby).
194194

@@ -215,6 +215,7 @@ products.
215215

216216
#### Complex Joins
217217

218+
##### Alias
218219
Where Arel really shines is in its ability to handle complex joins and aggregations. As a first example, let's consider an "adjacency list", a tree represented in a table. Suppose we have a table `comments`, representing a threaded discussion:
219220

220221
```ruby
@@ -240,6 +241,7 @@ comments_with_replies = \
240241

241242
This will return the reply for the first comment.
242243

244+
##### CTE
243245
[Common Table Expressions (CTE)](https://en.wikipedia.org/wiki/Common_table_expressions#Common_table_expression) support via:
244246

245247
Create a `CTE`
@@ -262,6 +264,7 @@ users.
262264
# FROM users INNER JOIN cte_table ON users.id = cte_table.user_id
263265
```
264266

267+
#### Write SQL strings
265268
When your query is too complex for `Arel`, you can use `Arel::SqlLiteral`:
266269

267270
```ruby

0 commit comments

Comments
 (0)