SQLDSL: A Ruby way to build SQL queries
SQLDSL, by Jay Fields, is, simply, "a library for creating SQL statements using Ruby code." Jay posted separately about the pros and cons of SQLDSL on his weblog, although he might be accused of bias with only one con to six pros (compelling as they may be).
Despite being another DSL to learn, SQLDSL follows SQL pretty closely (in contrast to ORM frameworks like ActiveRecord, Sequel, or Og):
Select[:column1].from[:table1].where do name = person_name end
And it even affords some clever logical tricks:
Select[:column1].from[:table1, :table2].where do table1.column1 = table2.table1_id table1.column2 >= quantity if quantity > 0 end
One major future benefit of SQLDSL is that it provides a programatic abstraction of SQL that's still pretty close to the database layer, and could allow for easy vendor-specific SQL manipulation in future. As Jay says:
The point is, as long as your sql is nothing more than a string it is not able to be easily modified. However, an object representation of your sql could be evaluated in various contexts to produce different results."