# ANN: Sequel 3.10.0 Released

**URL:** <https://www.ruby-forum.com/t/ann-sequel-3-10-0-released/186253>\
**Category:** Ruby\
**Created:** [April 2, 2010, 11:46pm UTC](https://www.ruby-forum.com/t/ann-sequel-3-10-0-released/186253 "2010-04-02T23:46:08Z")\
**Posts on this page:** 1\
**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:** [April 2, 2010, 11:46pm UTC](https://www.ruby-forum.com/t/ann-sequel-3-10-0-released/186253/1 "2010-04-02T23:46:08Z")

</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.10.0 has been released and should be available on the gem  
mirrors.

## New Features

- A real one\_to\_one association was added to Sequel, replacing the  
previous :one\_to\_one option of the one\_to\_many association.

- Both many\_to\_one and one\_to\_one associations now use before\_set  
and after\_set callbacks instead of trying to make the one\_to\_many  
and many\_to\_many associations’ (before|after)\_(add|remove)  
callbacks work.

- Dataset#for\_update was added as a default dataset method.  
Previously, it was only supported on PostgreSQL. It has been  
tested to work on PostgreSQL, MySQL, SQLite (where it is ignored),  
H2, and MSSQL.

- Dataset#lock\_style was added as a backbone for Dataset#for\_update,  
but allowing you to specify custom lock styles. These can either  
be symbols recognized by the adapters, or strings which are treated  
as literal SQL.

- Model#lock! was added, which uses Dataset#for\_update to lock model  
rows for specific instances. Combined with the Dataset#for\_update,  
Sequel now has an equivalent to ActiveRecord’s pessimistic locking  
support.

- A composition plugin was added, given similar functionality as  
ActiveRecord’s composed\_of.

- An rcte\_tree plugin was added, which uses recursive common table  
expressions to load all ancestors and descendants in a single  
query. If your database supports recursive common table  
expressions (PostgreSQL 8.4+, MSSQL 2005+, newer versions of  
Firebird), using recursive common table expressions to load  
all ancestors and descendants is significantly faster than storing  
trees as nested sets and using nested set queries. Usage:

- Dataset#first\_source\_table was added, giving you the unaliased  
version of the table for the first source.

- Add Sequel::BasicObject.remove\_methods!, useful on ruby 1.8 if you  
require other libraries after Sequel that add methods to Object.  
For example, if YAML is required after sequel, then the following  
will raise an error:

- Sequel associations now accept an :eager\_loader\_key option, which  
can be useful for associations to specify the column to use for the  
key\_hash for custom :eager\_loaders.

- A JDBC subadapter for the AS400 database was added.

## Other Improvements

- The one\_to\_one setter method and the one\_to\_many and many\_to\_many  
remove\_all methods now apply the association options (such as  
filters) on the appropriate dataset:

- Plugin loading now works correctly when the plugin module name  
is the same name as an already defined top level constant. This  
means that the active\_model plugin should now work correctly if  
you require active\_model before loading the Sequel plugin.

- The nested\_attributes plugin now preserves nested attributes for  
\*\_to\_one associations on validation failures.

- Transactions now work correctly on Oracle when using the JDBC  
adapter.

- Dataset#limit once again works correctly on MSSQL 2000. It was  
broken in Sequel 3.9.0.

- many\_to\_one associations now use limit(1) to ensure only one  
record is returned. If you don’t want this (because maybe you  
are using the :eager\_graph association option), you need to  
set the :key option to nil and use a custom :dataset option.

- many\_to\_one and one\_to\_many associations now work correctly  
with the association :eager option to eagerly load associations  
specified by :eager when lazy loading the association.

- The typecast\_on\_load plugin now correctly handles  
reloading/refreshing the object, both explicitly and implicitly  
on object creation.

- The schema parser and dumper now return tinyint columns as  
booleans when connecting to mysql using the do adapter, since  
DataObjects now returns the columns as booleans.

- The schema dumper now deals better with unusual or database  
specific primary key types when using the :same\_db option.

- On ruby 1.8, Sequel::BasicObject now undefs private methods in  
addition to public and protected methods. So the following  
code now works as expected:

- Sequel.connect with a block now returns the value of the block:

- MSSQL emulated offset support now works correctly when Sequel’s  
core extensions are not loaded.

- Sequel::BasicObject now works correctly on rubinius, and almost  
all Sequel specs now pass on rubinius.

- The nested\_attributes plugin now uses a better exception message  
no matching associated object is found.

- Sequel now raises a more informative error if you attempt to use  
the native sqlite adapter with the sqlite3 gem instead of the  
sqlite3-ruby gem.

- Multiple complex expressions with the same operator are now  
combined for simpler SQL:

- The Sequel::Model dataset methods (class methods proxied to the  
model’s dataset) and the Sequel::Dataset mutation methods  
(methods that have a ! counterpart to modify the object in place)  
have both been updated to use new dataset methods added in recent  
versions.

## Backwards Compatibility

- The :one\_to\_one option of the one\_to\_many associations now raises  
an exception. Please see the section above about the new real  
one\_to\_one association.

- The change to apply the association options to the one\_to\_many and  
many\_to\_many remove\_all methods has the potential to break some  
code that uses the remove\_all method on associations that use  
association options. This is especially true for many\_to\_many  
associations, as filters in many\_to\_many associations will often  
reference columns in the associated table, while the dataset  
used in the remove\_all method only contains the join table. Such  
cases should be handled by manually overriding the \_remove\_all  
association instance method in the class. It was determined that  
it was better to issue possibly invalid queries than to issue  
queries that make unexpected modifications.

- Dataset#group\_and\_count now longer orders the dataset by the count.  
Since it returns a modified dataset, if you want to order the  
dataset, just call order on the returned dataset.

- many\_to\_one associations now require a working :class option.  
Previously, if you provided a custom :dataset option, a working  
:class option was not required in some cases.

- The MSSQL shared adapter dataset methods switched from using  
the :table\_options internal option key to using the :lock internal  
option key.

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)]
- {Blog}[[http://sequel.heroku.com](http://sequel.heroku.com)]
- {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)]
