Sequel version 0.3.4 has just been released. This release includes a major improvement to column references, as well as a few other minor bug fixes and improvements. Sequel is a lightweight ORM library for Ruby. Sequel provides thread safety, connection pooling and a simple and expressive API for constructing database queries and table schemas. Following is a discussion of the changes: === Improved Column References The code relating to column references has been refactored and improved to provide better field quoting and more complete support for specifying SQL functions. You can now freely select literal values: DB.select(1, 'abc').sql #=> "SELECT 1, 'abc'" DB[:items].select(1, :items.all).sql #=> "SELECT 1, items.* FROM items" You can also alias literal values: DB.select(1.as(:a), 'abc'.as(:b)).sql #=> "SELECT 1 AS a, 'abc' AS b" SQL functions can also be used with any combination of literal arguments or column references, and can also be aliased: DB.select(:now[]).sql #=> "SELECT now()" DB.select(:date['now'].as(:cur_date)).sql #=> "SELECT date('now') AS cur_date" DB[:items].select(:avg[:price]).sql #=> "SELECT avg(price) FROM items" You can also use SQL functions for filtering and ordering records: DB[:items].group_by(:category).order_by(:count[:category].desc).sql #=> "SELECT * FROM items GROUP BY category ORDER BY count(category) DESC" DB[:items].filter {:now[] - :stamp > :sample_rate}.sql #=> "SELECT * FROM items WHERE ((now() - stamp) > sample_rate)" Also in this release is a new #cast_as method for converting SQL data types (for databases that support the cast function): DB[:items].select(:value.cast_as(:integer)).sql #=> "SELECT cast(value AS integer) FROM items" When you use Sequel with databases such as MySQL you will immediately enjoy the benefits of not having to quote fields by hand, no matter where they appear in your query: # Yes, this is a bit contrived... DB = Sequel('mysql://mydb') DB[:posts].filter(:category => 'ruby').order(:stamp.desc).sql #=> "SELECT * FROM posts WHERE (`category` = 'ruby') ORDER BY `stamp` DESC" === Other changes * Fixed error message in command-line tool if failed to load adapter (#85). * Tiny fix to Model#run_hooks. * Fixed MySQL adapter to allow calling stored procedures (thanks Sebastian). * Changed Dataset#each to always return self. === More info Sequel project page: <http://code.google.com/p/ruby-sequel> Sequel documentation: <http://sequel.rubyforge.org> Join the Sequel-talk group: <http://groups.google.com/group/sequel-talk> Install the gem: sudo gem install sequel Or check out the source and install manually: svn co http://ruby-sequel.googlecode.com/svn/trunk sequel cd sequel rake install