On Jun 3, 2012, at 7:35 AM, Andrew White wrote: > At some point (I don't know when) it was decided that rather than > constructing SQL out of string fragments, Rails 3 would use Arel to build SQL > but with a separate query interface that maintained backwards compatibility > but added functionality (ActiveRecord::Relation). However because Arel was > already quite well known by that point some people got the wrong end of the > stick, especially with the protracted development of Rails 3.
Coming from the perspective of an ActiveRecord adapter like SQL Server, I wish that both ActiveRecord and plugins alike used Arel more heavily. I know this is a doubled edged sword. You want end users of the framework to stay as high level as possible and not dip down to Arel. However, I see a need to expose Arel more for plugin developers to stop constructing SQL fragments from strings. The biggest pain from my perspective are order strings and select fragments. The SQL Server adapter's visitor needs to leverage real Arel ordering nodes since the visitor will have to eventually remove duplicates as TSQL does not allow "ORDER BY foo ASC, foo DESC". Other issues always come back to the way our adapter has to handle LIMIT and OFFSET using a paging function like ROW_NUMBER(). When plugin authors even use basic of SQL fragments like a SELECT... vs projections, it means we have to end up doing the parsing instead as we have to re-compose a complex statement to work with our window functions. The way I see, the more ActiveRecord and its plugins use Arel, the better off other adapters and engines can make decisions lower down the stack. I hope Rails core considers this as we move forward. - Ken -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.