Is Arel a public API or not? Arel.sql seems so lonely

ActiveRecord is the primary database interface rails provides. At the time of writing the edgeguides have no references to Arel at all (google search link). And the 7.1.1 docs have exactly one Arel method documented: Arel.sql (docs link).

At Rails World 2023 there was a question during the Rails Core AMA about if Arel table would ever be a public API, and the answer from Jeremy Daer was a definitive no. (youtube link - Rails Core AMA (t=17:38)).

I realize that this is a bit of a re-hashing, and that this discussion has been had at least twice before (1, 2), but given the definitive comment about Arel table, I’m confused why Arel is included at all. That one seemingly public Arel.sql method is jumping down a layer of abstraction that new people have not been introduced to. If the core team considers Arel to be a private API, then shouldn’t it be hidden? For example by handling it in the ActiveRecord query api (be that unsafe_sql_order/unsafe_sql_pluck or even a ActiveRecord.sql wrapper method)?

3 Likes

You can find some discussion on this over at https://github.com/rails/rails/issues/32995

Yup. That s the #2 link above. I participated in that conversation at the time. I raise it again because the comment at Rails World puts some of the statements in that thread in a different light. I’m left confused if the core team considers Arel to be a public or private api. And confused about this one little method of it poking into the surface of the documentation.

Oh, I’m sorry. Don’t know how I missed that you linked the issue yourself.