You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is to provide references and examples of how to rephrase SQL statements in AREL, which seems like a desirable intermediate step to making MO database-agnostic. Although there's a bit of a learning curve, i eventually felt it's not that hard to translate between the two. Those with a firmer understanding of query language may find it easier; on the other hand some of our queries may be more work to rephrase than i'm expecting.
First, some links. I personally needed a bit of handholding to get my head around what exactly Arel does, so others may find some of the latter links a bit verbose.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
This is to provide references and examples of how to rephrase SQL statements in AREL, which seems like a desirable intermediate step to making MO database-agnostic. Although there's a bit of a learning curve, i eventually felt it's not that hard to translate between the two. Those with a firmer understanding of query language may find it easier; on the other hand some of our queries may be more work to rephrase than i'm expecting.
First, some links. I personally needed a bit of handholding to get my head around what exactly Arel does, so others may find some of the latter links a bit verbose.
Composable Query Builders in Rails with Arel - For me, the clearest intro
Source code of Rails Arel Predications - Reference for query "prepositions" in AREL straight from the Rails GitHub repo
Queries on Rails - Active Record and Arel (2020) - Covers most use cases, I believe. very good
Composable SQL Queries in Rails Using Arel - Long but explanatory
How can you do a conditional where clause using AREL - StackOverflow q&a for the specific question I was dealing with in GraphQL, for filtered search
How to build complex queries using Arel - Considering the title, ironically the briefest of these
I'd like to follow up with specific examples of SQL/AREL query syntax.
Beta Was this translation helpful? Give feedback.
All reactions