Sequel version 1.1 has just been released. Sequel is a lightweight
access and ORM library for Ruby. Sequel provides thread safety,
pooling and a simple and expressive API for constructing database
The latest release of Sequel includes some major improvements to
classes, including implicit table names, support for virtual
better validations, as well as many improvements and bug fixes to the
core and the database adapters. Following is a discussion of the main
=== DRY Sequel models
With the new Sequel release you no longer need to explicitly specify
name for each model class, assuming your model name is the singular of
table name (just like in ActiveRecord or DataMapper):
class UglyBug < Sequel::Model
UglyBug.table_name #=> :ugly_bugs
=== New model validations and support for virtual attributes
Sequel model now include validation functionality which largly follows
validations offered in ActiveRecord. Validations can be checked
calling Model#valid?, with validation errors accessible through
class Item < Sequel::Model
my_item = Item.new
my_item.valid? #=> false
my_item.errors.full_messages #=> [“name is not present”]
The Model#save method has been changed to check for validity before
the model instance is not valid, the #save method returns false
the instance. You can also bypass the validity test by calling
Model classes also now support virtual attributes, letting you assign
any attribute (virtual or persistent) at initialization time:
class User < Sequel::Model
u = User.new(:password => ‘blah’, …)
u.password #=> ‘blah’
Also, virtual attributes can be validated just like persistent
=== Other changes (long list!)
Added Model#reload as alias to Model#refresh.
Changed Model.create to accept a block (#126).
Fixed Model#initialize to accept nil values (#115).
Added Model#update_with_params method with support for virtual
attributes and auto-filtering of unrelated parameters, and changed
Model.create_with_params to support virtual attributes (#128).
Fixed Model.dataset to correctly set the dataset if using implicit
naming or inheriting the superclass dataset (thanks celldee).
Finalized support for virtual attributes.
Fixed Model#set to work with string keys (#143).
Fixed Model.create to correctly initialize instances marked as new
Fixed Model#initialize to convert string keys into symbol keys. This
also fixes problem with validating objects initialized with string
Added Dataset#table_exists? convenience method.
Changed Dataset#group_and_count to accept multiple columns (#134).
Added Dataset#select_all method.
Added Dataset#select_more, Dataset#order_more methods (#129).
Fixed Dataset#count to work correctly for grouped datasets (#144).
Fixed joining datasets using aliased tables (#140).
Added support for UNSIGNED constraint, used in MySQL? (#127).
Implemented constraint definitions inside Database#create_table.
Enhanced Database.connect to accept options with string keys, so it
can now accept options loaded from YAML files. Database.connect also
automatically converts :username option into :user for compatibility
with existing YAML configuration files for AR and DataMapper.
Changed ODBC::Database to support connection using driver and
database name, also added support for untitled columns in
ODBC::Dataset (thanks Leonid Borisenko).
Changed MySQL adapter to support specifying socket option.
Fixed MySQL adapter to correctly format foreign key definitions
Changed MySQL::Dataset to allow HAVING clause on ungrouped datasets,
and put HAVING clause before ORDER BY clause (#133).
Changed mysql adapter to default to localhost if :host option is not
Added String#to_date. Updated mysql adapter to use String#to_date
for mysql date types (thanks drfreeze).
Fixed postgres adapter to define PGconn#async_exec as alias to #exec
if not defined (for pure-ruby postgres driver).
Changed postgres adapter to quote column references using double
Applied patch for oracle adapter: fix behavior of limit and offset,
transactions, #table_exists?, #tables and additional specs (thanks
Liming L. #122).
Added support additional field types in postgresql adapter (#146).
Added support for date field types in postgresql adapter (#145).
Added support for limiting and paginating datasets with fixed SQL,
e.g. using Database#fetch.
Added new Dataset#from_self method that returns a dataset selecting
from the original dataset.
Allow for additional filters on a grouped dataset (#119 and #120)
Refactored Sequelizer to use Proc#to_sexp (method provided by r2r).
Fixed bin/sequel to require sequel_model if available.
=== More info on Sequel
Sequel project page:
Join the Sequel-talk group:
Join Sequel discussion on IRC at #sequel.
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