# ANN: Sequel 0.3.4 Released

**URL:** <https://www.ruby-forum.com/t/ann-sequel-0-3-4-released/119773>\
**Category:** Ruby\
**Created:** [November 10, 2007, 10:55am UTC](https://www.ruby-forum.com/t/ann-sequel-0-3-4-released/119773 "2007-11-10T10:55:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ciconia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/71c47a/32.png) [@ciconia](https://www.ruby-forum.com/u/ciconia)\
**Post date:** [November 10, 2007, 10:55am UTC](https://www.ruby-forum.com/t/ann-sequel-0-3-4-released/119773/1 "2007-11-10T10:55:36Z")

</div>

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](http://code.google.com/p/ruby-sequel)

Sequel documentation:  
[http://sequel.rubyforge.org](http://sequel.rubyforge.org)

Join the Sequel-talk group:  
[http://groups.google.com/group/sequel-talk](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](http://ruby-sequel.googlecode.com/svn/trunk) sequel  
cd sequel  
rake install

---

<div class="post-metadata">

**Author:** ![ciconia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/71c47a/32.png) [@ciconia](https://www.ruby-forum.com/u/ciconia)\
**Post date:** [November 11, 2007, 12:05am UTC](https://www.ruby-forum.com/t/ann-sequel-0-3-4-released/119773/2 "2007-11-11T00:05:59Z")

</div>

2007/11/10, Sharon R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 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.

Looks very interesting. I’m using ActiveRecord + Informix right now  
with a legacy database, trying to avoid DBI, but sometimes AR  
requirements get in the way.
