# ANN: Sequel 3.24.0 Released

**URL:** <https://www.ruby-forum.com/t/ann-sequel-3-24-0-released/207746>\
**Category:** Ruby\
**Created:** [June 1, 2011, 6:50pm UTC](https://www.ruby-forum.com/t/ann-sequel-3-24-0-released/207746 "2011-06-01T18:50:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [June 1, 2011, 6:50pm UTC](https://www.ruby-forum.com/t/ann-sequel-3-24-0-released/207746/1 "2011-06-01T18:50:30Z")

</div>

Sequel is a lightweight database access toolkit for Ruby.

- Sequel provides thread safety, connection pooling and a concise  
DSL for constructing SQL queries and table schemas.
- Sequel includes a 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, savepoints,  
two-phase commit, transaction isolation, master/slave  
configurations, and database sharding.
- Sequel currently has adapters for ADO, Amalgalite, DataObjects,  
DB2, DBI, Firebird, Informix, JDBC, MySQL, Mysql2, ODBC, OpenBase,  
Oracle, PostgreSQL, SQLite3, Swift, and TinyTDS.

Sequel 3.24.0 has been released and should be available on the gem  
mirrors.

= Prepared Statement Plugins

- The prepared\_statements plugin makes Sequel::Model classes use  
prepared statements for creating, updating, and destroying model  
instances, as well as looking up model objects by primary key.  
With this plugin, all of the following will use prepared  
statements:

- The prepared\_statements\_safe plugin reduces the number of  
prepared statements that can be created by doing two things. First,  
it makes the INSERT statements used when creating instances to use  
as many columns as possible, setting specific values for all  
columns with parseable default values. Second, it changes  
save\_changes to just use save, saving all columns instead of just  
the changed ones.

- The prepared\_statements\_associations plugin allows normal  
association method calls to use prepared statements if possible.  
For example:

- The prepared\_statements\_with\_pk plugin allows the new  
Dataset#with\_pk method (explained below) to use prepared statements.  
For example:

= Other New Features

- Filtering by associations got a lot more powerful. Sequel 3.23.0  
introduced filtering by associations:

- Sequel now supports around hooks, which wrap the related before  
hook, behavior, and after hook. Like other Sequel hooks, these  
are implemented as instance methods. For example, if you wanted  
to log DatabaseErrors raised during save:

- Dataset#with\_pk has been added to model datasets that allows you  
to find the object with the matching primary key:

- Dataset#[] for model datasets will now call with\_pk if given a  
single Integer argument. This makes the above case even easier:

- Dataset#unbind has been added, which allows you to take a dataset  
that uses static bound values and convert them to placeholders.  
Currently, the only cases handled are SQL::ComplexExpression  
objects that use a =, !=, \<, \>, \<=, or \>= operator where the first  
argument is a Symbol, SQL::Indentifier, or  
SQL::QualifiedIdentifier, and the second argument is a Numeric,  
String, Date, or Time. Dataset#unbind returns a two element array,  
where the first element is a modified copy of the receiver, and the  
second element is a bound variable hash:

- A defaults\_setter plugin has been added that makes it easy to  
automatically set default values when creating new objects. This  
plugin makes Sequel::Model behave more like ActiveRecord in that  
new model instances (before saving) will have default values  
parsed from the database. Unlike ActiveRecord, only values with  
non-NULL defaults are set. Also, Sequel allows you to easily  
modify the default values used:

- A Database#views method has been added that returns an array  
of symbols representing view names in the database. This works  
just like Database#tables except it returns views.

- A Sequel::ASTTransformer class was added that makes it easy to  
write custom transformers of Sequel’s internal abstract syntax  
trees. Dataset#qualify now uses a subclass of ASTTransformer to do  
its transformations, as does the new Dataset#unbind.

= Other Improvements

- Database#create\_table? now uses a single query with IF NOT EXISTS  
if the database supports such syntax. Previously, it issued a  
SELECT query to determine table existence. Sequel currently  
supports this syntax on MySQL, H2, and SQLite 3.3.0+.

- Multiple column IN/NOT IN emulation now works correctly with  
model datasets (or other datasets that use a row\_proc).

- You can now correctly invert SQL::Constant instances:

- A bug in the association\_pks plugin has been fixed in the case  
where the associated table had a different primary key column name  
than the current table.

- The emulated prepared statement support now supports nil and false  
as bound values.

- The to\_dot extension was refactored for greater readability. The  
only change was a small fix in the display for SQL::Subscript  
instances.

- The Dataset#supports\_insert\_select? method is now available to let  
you know if the dataset supports insert\_select. You should use  
this method instead of respond\_to? for checking for insert\_select  
support.

- Prepared statements/bound variable can now use a new :insert\_select  
type for preparing a statement that will insert a row and return  
the row inserted, if the dataset supports insert\_select.

- The Model#initialize\_set private method now exists for easier plugin  
writing. It is only called for new model objects, with the hash  
given to initialize. By default, it just calls set.

- A small bug when creating anonymous subclasses of Sequel::Model on  
ruby 1.9 has been fixed.

- If Thread#kill is used inside a transaction on ruby 1.8 or  
rubinius, the transaction is rolled back. This situation is not  
handled correctly on JRuby or ruby 1.9, and I’m not sure it’s  
possible to handle correctly on those implementations.

- The postgres adapter now supports the  
Sequel::Postgres::PG\_NAMED\_TYPES hash for associating conversion  
procs for custom types that don’t necessarily have the same type  
oid on different databases. This hash uses symbol keys and  
proc values:

- On SQLite and MSSQL, literalization of true and false values given  
directly to Dataset#filter has been fixed. So the following now  
works correctly on those databases:

- The MySQL bit type is no longer treated as a boolean. On MySQL, the  
bit type is a bitfield, which is very different than the MSSQL bit  
type, which is the closest thing to a boolean on MSSQL.

- The bool database type is now recognized as a boolean. Some SQLite  
databases use bool, such as the ones used in Firefox.

- SQL\_AUTO\_IS\_NULL=0 is now set by default when connecting to MySQL  
using the swift or jdbc adapters. Previously, it was only set by  
default when using the mysql or mysql2 adapters.

- Dataset#limit now works correctly on Access, using the TOP syntax.

- Dataset#limit now works correctly on DB2, using the FETCH FIRST  
syntax.

- The jdbc mssql subadapter was split into separate subadapters for  
sqlserver (using Microsoft’s driver) and jtds (using the open  
source JTDS driver).

- The jdbc jtds subadapter now supports converting Java CLOB  
objects to ruby strings.

- Tables from the INFORMATION\_SCHEMA are now ignored when parsing  
schema on JDBC.

- The informix adapter has been split into shared/specific parts, and  
a jdbc informix subadapter has been added.

- Dataset#insert\_select now works correctly on MSSQL when the core  
extensions are disabled.

- The sqlite adapter now logs when preparing a statement.

- You no longer need to be a PostgreSQL superuser to run the postgres  
adapter specs.

- The connection pool specs are now about 10 times faster and not  
subject to race conditions due to using Queues instead of  
sleeping.

= Backwards Compatibility

- Model#save no longer calls Model#valid?. It now calls the  
Model#\_valid? private method that Model#valid? also calls. To mark  
a model instance invalid, you should override the Model#validate  
method and add validation errors to the object.

- The BeforeHookFailure exception class has been renamed to  
HookFailure since hook failures can now be raised by around hooks  
that don’t call super. BeforeHookFailure is now an alias to  
HookFailure, so no code should break, but you should update your  
code to reflect the new name.

- Any custom argument mappers used for prepared statements now need  
to implement the prepared\_arg? private instance method and have it  
return true.

- If your databases uses bit as a boolean type and isn’t MSSQL, it’s  
possible that those columns will no longer be treated as booleans.  
Please report such an issue on the bugtracker.

- It is possible that the filtering and excluding by association  
datasets will break backwards compatibility in some apps. This can  
only occur if you are using a symbol with the same name as an  
association with a model dataset whose model is the same as the  
associated class. As associations almost never have the same names  
as columns, this would require either aliasing or joining to  
another table. If for some reason this does break your app, you  
can work around it by changing the symbol to an SQL::Identifier or  
a literal string.

- The Sequel::Postgres.use\_iso\_date\_format= method now only affects  
future Database objects.

- On MySQL, Database#tables no longer returns view names, it only  
returns table names. You have to use Database#views to get view  
names now.

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}[[Issues · jeremyevans/sequel · GitHub](http://github.com/jeremyevans/sequel/issues)]
- {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)]
