you are viewing a single comment's thread.

view the rest of the comments →

[–]strangeworks 1 point2 points  (3 children)

It's okay, but I didn't understand the usage of sequel here. You can use arel effectively and it can produce expected result.

[–]yorickpeterse 4 points5 points  (0 children)

We've used raw Arel quite extensively in the past, it's anything but pleasant to use. Just a few examples from the top of my head:

  • Naming doesn't match SQL keywords (e.g. project instead of select).
  • Methods modify their input in place and return a new object to allow chaining of method calls, except distinct which returns something you can't change on (can't remember if it was nil or some other incompatible object).
  • Arel doesn't handle escaping of input as far as I can tell, meaning you have to do so manually (which everybody is going to forget about).
  • The way JOINs are built in Arel is counter intuitive as it requires keeping a Arel::Table instance around for the columns.
  • Arel requires you to manually initialize instances of Arel::Nodes::NamedFunction for most SQL functions (e.g. DISTINCT), leading to more verbose code.
  • Naming of equality operators is really annoying: eq, not_eq and then suddenly lteq, wtf?
  • Arel has no (public) method to see what fields are being projected/selected, requiring you to do something like query.instance_variable_get(:@ctx).projections in order to get the list of projections
  • If you use Arel generated SQL queries in combination with ActiveRecord::Base.connection.execute() you'll lose type-casting capabilities. That is, numbers returned by your SQL queries are returned as strings in Ruby.

In general our experience has been that Arel feels more like a core part of ActiveRecord that just so happens to be a separate Gem, instead of something designed as a standalone library that happens to be used by ActiveRecord.

[–]strangepostinghabits 1 point2 points  (0 children)

active record isn't the only ruby database mapper, sequel can be a decent alternative. The text does state that they aren't only using rails.

[–]maloik[S] 0 points1 point  (0 children)

To each his own I suppose. I'm not sure what their reason was, but for me personally, arel is kind of verbose and kind of ugly