|
|
|
|
|
by JohnBooty
2583 days ago
|
|
From what I've seen of Sequel is looks awesome and I've been dying for an excuse to use it. found [ActiveRecord] to be severely limited in
working with complex queries which use many
JOIN statement and sub-queries
I'd humbly suggest that this is not a flaw of ActiveRecord whatsoever! I think this is AR working exactly as designed.I would certainly agree that SQL > AR once your queries grow past a certain (fairly low) complexity threshold. But, AR (wisely) doesn't try to be a complete replacement for SQL. It very happily (and even elegantly, I might say?) lets you use raw SQL pretty much any time you, the developer, feel it's more convenient/productive. That principle is pretty explicitly baked into AR. Many ORM frameworks don't make this easy at all, whereas with AR it's very painless. I have a lot of beef with AR but I think this is one of its strong points. |
|
My biggest issue with AR is that the arbitrary SQL cannot be combined or reused in a way which leads to compositional queries. An example would be to break up a large SQL statement into several smaller statements and then recombine them in different ways, safely.
What I found with Ecto and ROM is that, while simple to low complexity SQL was about the same as AR, maybe 10% harder to understand, complex to very complex statements were about equivalent to their SQL counterparts and could be composed together. That was a major win over AR for non-trivial queries.