ANN: Sequel 0.1.6 Released


#1

Sequel version 0.1.6 has just been released. New in this release is
support for literal expressions, Dataset#or and Dataset#and, and the
default join type is INNER JOIN. Various bug fixes courtesy of snok.

Sequel is a lightweight ORM library for Ruby. Sequel provides thread
safety, connection pooling and a concise DSL for constructing database
queries and table schemas.

Literal expressions

You can now use literal expressions in filters or update values:

items.update_sql(:col2 => ‘col1 + 10’.expr) #=>
“UPDATE items SET col2 = col1 + 10”

items.exclude {col1 > ‘col2 + col3’.expr}.sql #=>
“SELECT * FROM items WHERE NOT (col1 > col2 + col3)”

Dataset#or, #and

Pretty much self-explanatory:

items.filter {col1 > 100}.or(:col2 => nil).sql #=>
“SELECT * FROM items WHERE (col1 > 100) OR (col2 IS NULL)”

items.filter {col1 > 100}.and(:col2 => nil).sql #=>
“SELECT * FROM items WHERE (col1 > 100) AND (col2 IS NULL)”

Default join type

On advice from a dude named snok, I changed the default join type to
INNER, since that’s what the SQL specs say. So now:

DB[:a].join(:b, :a_id).sql #=>
“SELECT * FROM a INNER JOIN b ON (b.a_id = a.id)”

SQLite Memory DB

The SQLite adapter always had support for memory DB’s:

Sequel.open ‘sqlite:/:memory:’

Well, now it’s even easier. Just omit the db name altogether:

Sequel.open ‘sqlite:/’

Miscelenea

  • Removed stub class methods from Model. Model.method_missing now
    automagically creates stub methods as needed. This is the first step
    on the way to turning the model class into a supercharged dataset, but
    that’s a topic for a separate post. Coming soon… :slight_smile:

  • Fixed PrettyTable code so now model datasets can be printed just
    like naked datasets (thanks snok).

  • Fixed Model#method_missing to raise if an unknown attribute is
    accessed. Up until now this was the cause for a lot of potential
    hidden errors, as unintended method calls would be swallowed and
    ignored.

  • Fixed ODBC timestamp conversion to support dates before 1970 and
    after 2040 (thanks snok.)

======================

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