# ANN: Sequel 3.6.0 Released

**URL:** <https://www.ruby-forum.com/t/ann-sequel-3-6-0-released/178317>\
**Category:** Ruby\
**Created:** [November 2, 2009, 7:57pm UTC](https://www.ruby-forum.com/t/ann-sequel-3-6-0-released/178317 "2009-11-02T19:57:20Z")\
**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:** [November 2, 2009, 7:57pm UTC](https://www.ruby-forum.com/t/ann-sequel-3-6-0-released/178317/1 "2009-11-02T19:57:20Z")

</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.6.0 has been released and should be available on the gem  
mirrors. The 3.6.0 release adds numerous improvements:

## New Features

- Dataset#filter and related methods now accept a string with named  
placeholders, and a hash with placeholder values:

- The Model add\_ association method now accepts a hash and creates  
a new associated model object associated to the receiver:

- The Model remove\_ association method now accepts a primary key  
and removes the associated model object from the association. For  
models using composite primary keys, an array of primary key values  
can be used. Example:

- Dataset#bind was added, allowing you to bind values before calling  
Dataset#call. This is more consistent with Sequel’s general  
approach where queries can be built in any order.

- The native postgres adapter now has Dataset#use\_cursor, which  
allows you to process huge datasets without keeping all records in  
memory. The default number of rows per cursor fetch is 1000, but  
that can be modified:

- The nested\_attributes plugin now adds newly created objects to the  
cached association array immediately, even though the changes  
are not persisted to the database until after the object is saved.  
The reasoning for this is that otherwise there is no way to access  
the newly created associated objects before the save, and no way  
to access them at all if validation fails.

- You can now easily override the default options used in the  
validation\_helpers plugin (the recommended validation plugin).  
Options can be overridden at a global level:

- You can now use a proc instead of a string for the  
validation\_helpers :message option. This should allow much  
easier internationalization support. If a proc is given, Sequel  
calls it to get the format string to use. Whether the proc should  
take an argument depends on whether the associated validation  
method takes an argument before the array of columns to validate,  
and the argument provided is what is passed to the proc. The  
exception to this is the validates\_not\_string method, which doesn’t  
take an argument, but does pass one to the proc (a symbol with the  
schema type of the column).

- The nested\_attributes plugin now accepts a :fields option that  
specifies the fields that are allowed. If specified, the  
plugin will use set\_only instead of set when mass assigning  
attributes. Without this, the only way to control which fields  
are allowed is to set allowed/restricted attributes at a class  
level in the associated class.

- Associations now accept a :distinct option which uses the SQL  
DISTINCT clause. This can be used instead of :uniq for  
many\_to\_many and many\_through\_many associations to handle  
the uniqueness in the database instead of in ruby. It can  
also be useful for one\_to\_many associations to models that  
don’t have primary keys.

- The caching plugin now accepts an :ignore\_exceptions option that  
allows it to work with memcached (which raises exceptions instead  
of returning nil for missing records).

- Sequel now emulates JOIN USING poorly using JOIN ON for databases  
that don’t support JOIN USING (MSSQL and H2). This isn’t  
guaranteed to work for all queries, since USING and ON have  
different semantics, but should work in most cases.

- The MSSQL shared adapter now supports insert\_select, for faster  
model object creation. If for some reason you need to disable it,  
you can use disable\_insert\_output.

- Model#modified! has been added which explicitly marks the object  
as modified. So even if no column values have been modified,  
calling save\_changes/update will still run through the regular  
save process and call all before and after save/update hooks.

- Model#marshallable! has been added which removes unmarshallable  
attributes from the object. Previously, you couldn’t marshal  
a saved model object because it contained a dataset with a  
singleton class. Custom \_dump and \_load methods could be used  
instead, but this approach is easier to implement.

- Dataset#literal\_other now calls sql\_literal on the object with  
the current dataset instance, if the object responds to it.  
This makes it easier to support the literalization of arbitrary  
objects.

- Model#save\_changes now accepts an option hash that is passed to  
save:

- A bunch of Dataset#\*\_join methods have been added, for specific  
join types:

- You can now create clustered indexes on Microsoft SQL Server using  
the :clustered option.

- AssociationReflection#associated\_object\_keys has been added,  
specifying the keys in the associated model object that are related  
to this association.

- Sequel::SQL::SQLArray#to\_a was added.

## Other Improvements

- Constant lookup in virtual row blocks now works correctly in ruby  
1.9. Virtual row blocks are based on BasicObject on ruby 1.9,  
which doesn’t allow referencing objects in the top level scope. So  
the following code would cause an error on 1.9:

- Sequel no longer attempts to load associated objects when  
one of the key fields in the current table is NULL. This fixes  
the behavior when the :primary\_key option for the association  
is used to point to a non-primary key.

- Dataset aggreate methods (sum/avg/min/max/range/interval) now  
work correctly with limited, grouped, or compound datasets.  
Previously, count worked with them, but other aggregate methods  
did not. These methods now use a subquery if called on a  
limited, grouped or compound dataset.

- It is no longer required to have an existing GROUP BY clause  
to use a HAVING clause (except on SQLite, which doesn’t permit  
it). Sequel has always had this limitation, but it’s not required  
by the SQL standard, and there are valid reasons to use HAVING  
without GROUP BY.

- Sequel will now emulate support for databases that don’t support  
multiple column IN/NOT IN syntax, such as MSSQL and SQLite:

- Sequel now emulates :column.ilike(‘blah%’) for case insensitive  
searches on MSSQL and H2. MSSQL is case insensitive by default,  
so it is the same as like. H2 is case sensitive, so Sequel  
uses a case insensitive cast there.

- The nested\_attributes plugin no longer allows modification of  
keys related to the association. This fixes a possible security  
issue with the plugin, where a user could associate the nested  
record to a different record. For example:

- The one\_to\_many remove\_\* association method now makes sure that the  
object to be removed is currently associated to this object.  
Before, the method could be abused to disassociate the object from  
whatever object it was associated to.

- Model add\_ and remove\_ association methods now check that the passed  
object is of the correct class.

- Calling the add\_\* association method no longer adds the record  
to the cached association array if the object is already in the  
array. Previously, Sequel did this for reciprocal associations,  
but not for regular associations.

- An array with a string and placeholders that is passed to  
Dataset#filter is no longer modified. Previously:

- Getting the most recently inserted autoincremented primary key  
is now optimized when connecting to MySQL via JDBC.

- Model.inherited now calls Class.inherited.

- The MSSQL shared adapter once again works on ruby 1.9. It was  
broken in 3.5.0 due to minor syntax issues.

- The force\_encoding plugin now handles refreshing an existing  
object, either explicitly or implicitly when new objects are  
created.

- Using nil as a bound variable now works on PostgreSQL. Before,  
Sequel would incorrectly use “” instead of NULL, since it  
transformed all objects to strings before binding them. Sequel  
now binds the objects directly.

- The Amalgalite adapter is now significantly faster, especially for  
code that modifies the schema or submits arbitrary SQL statements  
using Database \<\<, run, or execute\_ddl.

- Model#save\_changes is now used when updating existing associated  
objects in the nested\_attributes plugin. This should be  
significantly faster for the common case of submitting a complex  
form with nested objects without making modifications.

- You can now prepare insert statements that take multiple arguments,  
such as insert(1, 2, 3) and insert(columns, values).

- Dataset#group\_and\_count now supports aliased columns.

- Adding indexes to tables outside the default schema now works.

- Eager graphing now works better with models that use aliased tables.

- Sequel now correctly parses the column schema information for tables  
in a non-default schema on Microsoft SQL Server.

- changed\_columns is now cleared for when saving new model objects  
for adapters that support insert\_select, such as PostgreSQL.

- Dataset#replace on MySQL now works correctly when default values  
are used.

- Dataset#lock on PostgreSQL now works correctly.

- Dataset#explain now works correctly on SQLite, and works using  
any adapter. It also works correctly on Amalgalite.

- The JDBC adapter now handles binding Time arguments correctly when  
using prepared statements.

- Model add\_ and remove\_ association methods now have more  
descriptive exception messages.

- Dataset#simple\_select\_all? now ignores options that don’t affect  
the SQL, such as :server.

- Dataset#window in the PostgreSQL adapter now respects existing  
named windows.

- Sequel now better handles a failure to begin a new transaction.

- The dataset code was split into some additional files for improved  
readability.

- Many documentation improvements were made.

## Backwards Compatibility

- Model::Errors no longer uses a default proc, but emulates one in the  
[] method. This is unlikely to have a negative affect unless you  
are calling a method on it that doesn’t call [] (maybe using it in  
a C extension?).

- Model#table\_name now only provides the alias if an aliased table is  
used.

- The Sequel::Dataset::STOCK\_COUNT\_OPTS constant has been removed.

- Dataset#lock on PostgreSQL now returns nil instead of a dataset.

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)]
