# ANN: Sequel 3.4.0 Released

**URL:** <https://www.ruby-forum.com/t/ann-sequel-3-4-0-released/174822>\
**Category:** Ruby\
**Created:** [September 2, 2009, 7:02pm UTC](https://www.ruby-forum.com/t/ann-sequel-3-4-0-released/174822 "2009-09-02T19:02:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nerdmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c68b51/32.png) [@nerdmaster](https://www.ruby-forum.com/u/nerdmaster)\
**Post date:** [September 2, 2009, 7:02pm UTC](https://www.ruby-forum.com/t/ann-sequel-3-4-0-released/174822/1 "2009-09-02T19:02:54Z")

</div>

Sequel is a lightweight database access toolkit for Ruby.

- Sequel provides thread safety, connection pooling and a concise DSL  
for constructing database queries and table schemas.
- Sequel also includes a lightweight but comprehensive ORM layer for  
mapping records to Ruby objects and handling associated records.
- Sequel supports advanced database features such as prepared  
statements, bound variables, stored procedures, master/slave  
configurations, and database sharding.
- Sequel makes it easy to deal with multiple records without having  
to break your teeth on SQL.
- Sequel currently has adapters for ADO, Amalgalite, DataObjects,  
DB2, DBI, Firebird, Informix, JDBC, MySQL, ODBC, OpenBase, Oracle,  
PostgreSQL and SQLite3.

Sequel 3.4.0 has been released and should be available on the gem  
mirrors. The 3.4.0 release adds numerous improvements:

## New Plugins

- A nested\_attributes plugin was added allowing you to modify  
associated objects directly through a model object, similar to  
ActiveRecord’s Nested Attributes.

- A timestamps plugin was added for automatically adding  
before\_create and before\_update hooks for setting values on  
timestamp columns. There are a couple of existing external  
plugins that handle timestamps, but the implementations are  
suboptimal. The new built-in plugin supports the following  
options (with the default in parentheses):

- An instance\_hooks plugin was added for adding hooks to specific  
w  
model instances:

- A boolean\_readers plugin was added for creating attribute? methods  
for boolean columns. This can provide a nicer API:

## Other New Features

- Sequel now has support for converting Time/DateTime to local or UTC  
time upon storage, retrieval, or typecasting.

- Dataset#truncate was added for truncating tables. Truncate allows  
for fast removal of all rows in a table.

- Sequel now supports typecasting a hash to date, time, and datetime  
types. This allows easy usage of Sequel with forms that split  
the entry of these database types into separate from fields.  
With this code, you can just have field names like:

- validates\_unique now takes a block that can be used to scope the  
uniqueness constraint. This allows you to easily set up uniqueness  
validations that are only necessary in a given scope. For example,  
a validation on username, but only for active users (as inactive  
users are soft deleted but remain in the table). You just pass a  
block to validates\_unique:

- The serialization plugin now supports json.

- Sequel now supports generic concepts of  
CURRENT\_{DATE,TIME,TIMESTAMP}. Most databases support these SQL  
concepts, but not all, and some implementations act differently.

- Database#run was added for executing arbitrary SQL on a database.  
It’s an alias for Database#\<\<, but it allows for a nicer API inside  
migrations, since you can now do:

- Sequel::Model() can now take a database argument in addition to  
a symbol or dataset argument. If a database is given, it’ll create  
an anonymous subclass attached to the given database. Other changes  
were made to allow the following code to work:

- Dataset#ungrouped was added for removing a grouping from an  
existing dataset. Also, Dataset#group when called with no arguments  
or with a nil argument also removes any existing grouping instead  
of resulting in invalid SQL.

- Model#modified? was added, letting you know if the model has been  
modified. If the model hasn’t been modified, calling  
Model#save\_changes will do nothing.

- SQL::OrderedExpression now supports #asc, #desc, and #invert.

## Other Improvements

- The serialization and lazy\_attribute plugins now add accessor  
methods to a module included in the class, instead of to the  
model class itself. This allows the methods to be overridden  
in the class and work well with super, as well for the plugins  
to work together on the same column. Make sure the  
lazy\_attributes accessor is setup before the serialization  
accessor if you want to have a lazy serialized column.

- Calling the add\_\* method for many\_to\_many association now saves the  
record if the record is new. This makes it operate more similarly  
to one\_to\_many associations. Previously, it raised an Error.

- Dataset#import now works correctly when called with a dataset.  
Previously, it generated incorrect SQL.

- The JDBC adapter now converts byte arrays to/from SQL::Blob.

- The JDBC adapter now attempts to bind unknown types using  
setObject instead of raising, so it can work with native Java  
objects. It also binds boolean parameters correctly.

- Using multiple emulated ALTER TABLE statements (such as  
drop\_column) in a single alter\_table block now works correctly  
on SQLite.

- Database#indexes now works on JDBC for tables in a non-default  
schema. It also now properly detects unique indexes on MSSQL.

- Database#schema on JDBC now accepts a :schema option. Also,  
returned schema hashes now include a :column\_size entry specifying  
the maximum length/precision for the column, since the  
:db\_type entry doesn’t have contain the information on JDBC.

- Datasets without tables now work correctly on Oracle, so things  
like DB.get(…) now work.

- A descriptive error message is given if you attempt to use  
Sequel with the mysql.rb driver (which Sequel doesn’t support).

- The postgres adapter now works correctly with a modified  
postgres-pr that raises PGErrors instead of RuntimeErrors  
(e.g. [GitHub - jeremyevans/sequel-postgres-pr: A pure-Ruby (pr) library for accessing PostgreSQL databases](http://github.com/jeremyevans/postgres-pr)).

- You now get a Sequel::InvalidOperation instead of a NoMethodError  
if you attempt to update a dataset without a table.

- The inflection support has been modified to reduce code  
duplication.

## Backwards Compatibility

- Sequel now includes fractional seconds in timestamps for all  
adapters except MySQL. It’s possible that this may break  
timestamp columns for databases that are not regularly tested.

- Sequel now includes timezone values in timestamps on Microsoft  
SQL Server, Oracle, PostgreSQL and SQLite. The modification for  
SQLite is probably the biggest cause for concern, since SQLite  
stores times as text. If you have an SQLite database that uses  
timestamps and is accessed by something other than Sequel, you  
should make sure that it works with the timestamp format that  
Sequel now uses.

- The default timestamp format used by Sequel now uses a space  
instead of ‘T’ between the date and time parts, which could  
possibly affect some databases that are not regularly tested.

- Attempting to insert into a grouped dataset or a dataset that  
selects from multiple tables will now raise an Error. Previously,  
it would ignore any GROUP or JOIN settings and generate bad SQL if  
there were multiple FROM tables.

- Database#\<\< now always returns nil. Before, the return value was  
adapter dependent.

- ODBC::Time and ODBC::DateTime values are now converted to the  
Sequel.datetime\_class. Before, ODBC::Time used Time and  
ODBC::DateTime used DateTime regardless of the  
Sequel.datetime\_class setting.

- The default inflections were modified, fixing some obvious errors  
and possibly changing some existing inflections. Further changes  
to the default inflections are unlikely.

Thanks,  
Jeremy

- {Website}[[http://sequel.rubyforge.org](http://sequel.rubyforge.org)]
- {Source code}[[GitHub - jeremyevans/sequel: Sequel: The Database Toolkit for Ruby](http://github.com/jeremyevans/sequel)]
- {Bug tracking}[[Google Code Archive - Long-term storage for Google Code Project Hosting.](http://code.google.com/p/ruby-sequel/issues/list)]
- {Google group}[[http://groups.google.com/group/sequel-talk](http://groups.google.com/group/sequel-talk)]
- {RDoc}[[http://sequel.rubyforge.org/rdoc](http://sequel.rubyforge.org/rdoc)]

---

<div class="post-metadata">

**Author:** ![nerdmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c68b51/32.png) [@nerdmaster](https://www.ruby-forum.com/u/nerdmaster)\
**Post date:** [September 2, 2009, 8:00pm UTC](https://www.ruby-forum.com/t/ann-sequel-3-4-0-released/174822/2 "2009-09-02T20:00:02Z")

</div>

On Wednesday 02 September 2009 10:03:07 am Jeremy E. wrote:

> to break your teeth on SQL.
> 
> - A nested\_attributes plugin was added allowing you to modify
> 
> - A boolean\_readers plugin was added for creating attribute? methods  
> db\_schema[c][:db\_type] =~ /\Atinyint/
> 
> - Sequel now supports typecasting a hash to date, time, and datetime  
> {‘date’=\>{‘year’=\>?, ‘month’=\>?, ‘day’=\>?}}  
> a validation on username, but only for active users (as inactive
> 
> - Model#modified? was added, letting you know if the model has been  
> model class itself. This allows the methods to be overridden  
> Previously, it generated incorrect SQL.
> 
> - Sequel now includes timezone values in timestamps on Microsoft
> 
> - {Source code}[[GitHub - jeremyevans/sequel: Sequel: The Database Toolkit for Ruby](http://github.com/jeremyevans/sequel)]
> 
> - {Bug tracking}[[Google Code Archive - Long-term storage for Google Code Project Hosting.](http://code.google.com/p/ruby-sequel/issues/list)]
> 
> - {Google group}[[http://groups.google.com/group/sequel-talk](http://groups.google.com/group/sequel-talk)]
> 
> - {RDoc}[[http://sequel.rubyforge.org/rdoc](http://sequel.rubyforge.org/rdoc)]

Jeremy,

Thanks for all your hard work on Sequel. It is by far one of my favorite  
libraries in the Ruby world.

- spox

---

<div class="post-metadata">

**Author:** ![nerdmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c68b51/32.png) [@nerdmaster](https://www.ruby-forum.com/u/nerdmaster)\
**Post date:** [September 2, 2009, 9:50pm UTC](https://www.ruby-forum.com/t/ann-sequel-3-4-0-released/174822/3 "2009-09-02T21:50:08Z")

</div>

On Wed, Sep 2, 2009 at 12:03 PM, Jeremy E.[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Sequel is a lightweight database access toolkit for Ruby.

Who are you Jeremy and team? Do you even have time to sleep? Best  
library ever.

Todd

---

<div class="post-metadata">

**Author:** ![nerdmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c68b51/32.png) [@nerdmaster](https://www.ruby-forum.com/u/nerdmaster)\
**Post date:** [September 3, 2009, 3:39am UTC](https://www.ruby-forum.com/t/ann-sequel-3-4-0-released/174822/4 "2009-09-03T03:39:17Z")

</div>

IÃ±aki Baz C. wrote:

> El MiÃ©rcoles, 2 de Septiembre de 2009, Jeremy E. escribiÃ³:
> 
> > Sequel is a lightweight database access toolkit for Ruby.
> 
> Could you provide a short comparison between Sequel and DataMapper?  
> I’m just starting a project and have no chosen yet.
> 
> Thanks a lot.

Sequel only works with SQL databases. DataMapper works with non-SQL  
databases. So if you plan to use a non-SQL database, you definitely  
want DataMapper. If you plan to use an SQL database, Sequel is a better  
choice, IMO.

You may want to look at the Why DataMapper page  
([http://www.datamapper.org/doku.php?id=why\_datamapper](http://www.datamapper.org/doku.php?id=why_datamapper)), for the reasons  
why the DataMapper developers recommend DataMapper. However, that page  
needs updating, as Sequel has optional support for an identity map, lazy  
attributes, and strategic eager loading.

Unfortunately, I haven’t put together a similar advocacy page for Sequel  
yet. The closest thing to it is probably the presentations I’ve given  
(see [http://sequel.rubyforge.org/documentation.html](http://sequel.rubyforge.org/documentation.html)).

Jeremy

---

<div class="post-metadata">

**Author:** ![nerdmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c68b51/32.png) [@nerdmaster](https://www.ruby-forum.com/u/nerdmaster)\
**Post date:** [September 2, 2009, 10:19pm UTC](https://www.ruby-forum.com/t/ann-sequel-3-4-0-released/174822/5 "2009-09-02T22:19:24Z")

</div>

El MiÃ©rcoles, 2 de Septiembre de 2009, Jeremy E. escribiÃ³:

> Sequel is a lightweight database access toolkit for Ruby.

Could you provide a short comparison between Sequel and DataMapper?  
I’m just starting a project and have no chosen yet.

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![nerdmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c68b51/32.png) [@nerdmaster](https://www.ruby-forum.com/u/nerdmaster)\
**Post date:** [September 3, 2009, 4:46pm UTC](https://www.ruby-forum.com/t/ann-sequel-3-4-0-released/174822/6 "2009-09-03T16:46:55Z")

</div>

IÃ±aki Baz C. wrote:

> 2009/9/3 Jeremy E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
> 
> > Â If you plan to use an SQL database, Sequel is a better choice, IMO.
> 
> Could I know some reason? Is it more efficient?  
> I don’t need cool features (just transaction support and maybe  
> prepared statement). I would prefer the faster solution.

DataMapper probably has a greater emphasis on performance than Sequel  
does, but I haven’t done any comparative benchmarking between the two.  
FWIW, if performance is the most important criteria, I’m not sure why  
you’d pick ruby as the implementation language.

In any case, Sequel does support transactions and prepared statements.  
I know DataMapper supports transactions, but I’m not sure about prepared  
statements.

For further details, you should probably read the documentation I linked  
previously.

Jeremy

---

<div class="post-metadata">

**Author:** ![nerdmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c68b51/32.png) [@nerdmaster](https://www.ruby-forum.com/u/nerdmaster)\
**Post date:** [September 3, 2009, 8:24pm UTC](https://www.ruby-forum.com/t/ann-sequel-3-4-0-released/174822/7 "2009-09-03T20:24:55Z")

</div>

El Jueves, 3 de Septiembre de 2009, Jeremy E. escribiÃ³:

> DataMapper probably has a greater emphasis on performance than Sequel  
> does, but I haven’t done any comparative benchmarking between the two.

I expected that DataMapper is more oriented to be a ORM while Sequel is  
like  
an abstract SQL layer not so oriented to be a ORM. In this way, I really  
expected that Sequel was more efficient.

> FWIW, if performance is the most important criteria, I’m not sure why  
> you’d pick ruby as the implementation language.

It’s important, but not the only criteria 🙂

> In any case, Sequel does support transactions and prepared statements.  
> I know DataMapper supports transactions, but I’m not sure about prepared  
> statements.

Yes, it does.

> For further details, you should probably read the documentation I linked  
> previously.

I did 🙂

Thanks.

---

<div class="post-metadata">

**Author:** ![nerdmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c68b51/32.png) [@nerdmaster](https://www.ruby-forum.com/u/nerdmaster)\
**Post date:** [September 3, 2009, 12:24pm UTC](https://www.ruby-forum.com/t/ann-sequel-3-4-0-released/174822/8 "2009-09-03T12:24:11Z")

</div>

2009/9/3 Jeremy E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Sequel only works with SQL databases. Â DataMapper works with non-SQL  
> databases. Â So if you plan to use a non-SQL database, you definitely  
> want DataMapper.

I just use SQL databases.

> Â If you plan to use an SQL database, Sequel is a better choice, IMO.

Could I know some reason? Is it more efficient?  
I don’t need cool features (just transaction support and maybe  
prepared statement). I would prefer the faster solution.

Thanks a lot.
