# ANN: Sequel 2.12.0 Released

**URL:** <https://www.ruby-forum.com/t/ann-sequel-2-12-0-released/164666>\
**Category:** Ruby\
**Created:** [April 3, 2009, 7:31pm UTC](https://www.ruby-forum.com/t/ann-sequel-2-12-0-released/164666 "2009-04-03T19:31:36Z")\
**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 3, 2009, 7:31pm UTC](https://www.ruby-forum.com/t/ann-sequel-2-12-0-released/164666/1 "2009-04-03T19:31:36Z")

</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, DataObjects, DB2, DBI,  
Firebird, Informix, JDBC, MySQL, ODBC, OpenBase, Oracle, PostgreSQL  
and SQLite3.

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

## Overview

Sequel 2.12 is really just a stepping stone to Sequel 3.0, which will  
be released next month. All major changes currently planned for 3.0  
have been made in 2.12, but 2.12 contains many features that have  
been deprecated and will be removed or moved into extensions or  
plugins in 3.0.

## Deprecation Logging

If you use a deprecated method or feature, Sequel will by default  
print a deprecation message and 10 lines of backtrace to standard  
error to easily allow you to figure out which code needs to be  
updated. You can change where the deprecation messages go and how  
many lines of backtrace are given using the following:

# Log deprecation information to a file

Sequel::Deprecation.output = File.open(‘deprecated.txt’, ‘wb’)

# Use 5 lines of backtrace when logging deprecation messages

Sequel::Deprecation.backtraces = 5

# Use all backtrace lines when logging deprecation messages

Sequel::Deprecation.backtraces = true

# Don’t include backtraces in the deprecation logging

Sequel.Deprecation.backtraces = false

# Turn off all deprecation logging

Sequel::Deprecation.output = nil

## Deprecated Features Moving to Extensions

- Migrations are being moved into sequel/extensions/migration. There  
isn’t any reason that they should be loaded in normal use since  
they are used so rarely. The sequel command line tool uses this  
extension to run the migrations.

- Adding the blank? method to all objects has been moved into  
sequel/extensions/blank.

- Dataset#print and Sequel::PrettyTable have been moved into  
sequel/extensions/pretty\_table.

- Dataset#query and related methods have been moved into  
sequel/extensions/query.

- Dataset#paginate and related methods have been moved into  
sequel/extensions/pagination.

- String inflection methods (e.g. “people”.singularize) have been  
moved into sequel/extensions/inflector.

- String date/time conversion methods (e.g. ‘2000-01-01’.to\_date)  
have been moved into sequel/extensions/string\_date\_time.

## Deprecated Model Features Moving to Plugins

- Model validation class methods have been moved to a plugin. Sequel  
users are encouraged to write their own validate instance method  
instead. A new validation\_helpers plugin has been added to make  
this easier, it’s explained in the New Features section. If you  
want to continue using the validation class methods:

- Model hook class methods have been moved to a plugin. Sequel users  
are encouraged to write their own hook instance methods, and call  
super to get hooks specified in superclasses or plugins. If you  
want to continue using the hook class methods:

- Model schema methods (e.g. Model.set\_schema, Model.create\_table,  
Model.drop\_table) have been moved to a plugin. The use of these  
methods has been discouraged for a long time. If you want to use  
them:

- Model.set\_sti\_key has been moved to a plugin. So you should  
change:

- Model.set\_cache has been moved to a plugin. So you should change:

- Model.serialize has been moved to a plugin. So you should change:

## Deprecated Features To Be Removed in Sequel 3.0

- Dataset#transform is deprecated without any replacement planned.  
It was announced on the Sequel mailing list that transforms would  
be removed unless someone said they needed them, and nobody said  
that they did.

- Dataset#multi\_insert and Dataset#import are no longer aliases  
of each other. Dataset#multi\_insert now takes an array of hashes,  
and Dataset#import now takes an array of columns and an array  
of arrays of values. Using multi\_insert with import’s API or  
vice-versa is deprecated.

- Calling Dataset#[] with no arguments or an integer argument is  
deprecated.

- Calling Dataset#map with both an argument and a block is  
deprecated.

- Database#multi\_threaded? and Database#logger are both deprecated.

- Calling Database#transaction with a symbol to specify which server  
to use is deprecated. You should now call it with an option hash  
with a :server key.

- Array#extract\_options! and Object#is\_one\_of? are both deprecated.

- The metaprogramming methods taken from metaid are deprecated and  
have been moved into Sequel::Metaprogramming. If you want them  
available to specific objects/classes, just include or extend with  
Sequel::Metaprogramming. If you want all objects to have access to  
the metaprogramming methods, install metaid. Note that the  
class\_def method from metaid doesn’t exist in  
Sequel::Metaprogramming, since it really isn’t different from  
define\_method (except it is public instead of private).

- Module#class\_attr\_overridable, #class\_attr\_reader, and  
#metaalias are deprecated.

- Using Model#set or #update when the columns for the model are not  
set and you provide a hash with symbol keys is deprecated.  
Basically, you must have setter methods now for any columns used in  
#set or #update.

- Model#set\_with\_params and #update\_with\_params are deprecated, use  
#set and #update instead.

- Model#save! is deprecated, use #save(:validate=\>false).

- Model.is and Model.is\_a are deprecated, use Model.plugin.

- Model.str\_columns, Model#str\_columns, #set\_values, and  
#update\_values are deprecated. You should use #set and  
#update instead of #set\_values and #update\_values, though they  
operate differently.

- Model.delete\_all, Model.destroy\_all, Model.size, and Model.uniq  
are deprecated, use .delete, .destroy, .count, and .distinct.

- Model.belongs\_to, Model.has\_many, and Model.has\_and\_belongs\_to\_many  
are deprecated, use .many\_to\_one, .one\_to\_many, and .many\_to\_many.

- Model#dataset is deprecated, use Model.dataset.

- SQL::CastMethods#cast\_as is deprecated, use #cast.

- Calling Database#schema without a table argument is deprecated.

- Dataset#uniq is deprecated, use Dataset#distinct.

- Dataset#symbol\_to\_column\_ref is deprecated, use #literal.

- Dataset#quote\_column\_ref is deprecated, use #quote\_identifier.

- Dataset#size is deprecated, use #count.

- Passing options to Dataset#each, #all, #single\_record,  
#single\_value, #sql, #select\_sql, #update, #update\_sql, #delete,  
#delete\_sql, and #exists is deprecated. Modify the options first  
using clone or a related method, then call one of the above  
methods.

- Dataset#create\_view and #create\_or\_replace\_view are deprecated,  
use the database methods instead.

- Dataset.dataset\_classes, #model\_classes, #polymorphic\_key, and  
#set\_model are deprecated.

- Database#\>\> is deprecated.

- String#to\_blob and SQL::Blob#to\_blob are deprecated, use  
#to\_sequel\_blob.

- The use of Symbol#| to create array subscripts is deprecated,  
use Symbol#sql\_subscript.

- Symbol#to\_column\_ref is deprecated, use Dataset#literal.

- String#expr is deprecated, use String#lit.

- Array#to\_sql, String#to\_sql, and String#split\_sql are deprecated.

- Passing an array to Database#\<\< is deprecated.

- Range#interval is deprecated.

- Enumerable#send\_each is deprecated.

- When using ruby 1.8, Hash#key is deprecated.

- Sequel.open is deprecated, use Sequel.connect.

- Sequel.use\_parse\_tree and Sequel.use\_parse\_tree= are deprecated.

- All upcase\_identifier methods and the :upcase\_identifiers database  
option are deprecated, use identifier\_input\_method = :upcase  
instead.

- Using a virtual row block without an argument is deprecated, see  
Sequel.virtual\_row\_instance\_eval= under New Features.

- When using the JDBC adapter, Java::JavaSQL::Timestamp#usec is  
deprecated. Sequel has returned Java::JavaSQL::Timestamp as  
DateTime or Time for a few versions, so this shouldn’t affect most  
people.

- Sequel will no longer require bigdecimal/util, enumerator, or yaml  
in 3.0. If you need them in your code, make sure you require  
them yourself. Using features added by requiring these standard  
libaries will not bring up a deprecation warning, for obvious  
reasons.

- Sequel::Error::InvalidTransform, Sequel::Error::NoExistingFilter,  
and Sequel::Error::InvalidStatement exceptions will be removed in  
Sequel 3.0. You will not get a deprecation message if you reference  
them in 2.12.

- Sequel::Model::Validation::Errors is deprecated, use  
Sequel::Model::Errors instead. Referencing the old name will not  
bring up a deprecation message.

## New Features

- Sequel.virtual\_row\_instance\_eval= was added, which lets you give  
Sequel 2.12 the behavior that will be the standard in 3.0.  
It changes blocks passed to Dataset#filter, #select, or #order that  
don’t accept arguments (or accept any number of arguments) to  
instance eval the block in the context of a new VirtualRow  
instance instead of passing a new VirtualRow instance to the block.  
It allows you to change code that looks like this:

- A validation\_helpers model plugin was added that allows you to do  
validations similar to the old class level validations inside  
the Model#validate instance method. The API has changed, but it’s  
capable of most of the same validations. It doesn’t handle  
acceptance\_of or confirmation\_of validations, as those shouldn’t be  
handled in the model.

- MySQL adapter datasets now have on\_duplicate\_key\_update and  
insert\_ignore methods which modify the SQL used to support  
ON DUPLICATE KEY UPDATE and INSERT INGORE syntax in multi\_insert  
and import.

- If you use the MySQL native adapter, you can set:

- You can now use Sequel without modifying any core classes, by  
defining a SEQUEL\_NO\_CORE\_EXTENSIONS constant or environment  
variable. In 2.12, this may still add some deprecated methods to  
the core classes, but in 3.0 no methods will be added to the core  
classes if you use this.

- You can now use Sequel::Model without the associations  
implementation by defining a SEQUEL\_NO\_ASSOCIATIONS constant or  
environment variable.

## Other Improvements

- Model column accessors have been made faster and the overhead of  
creating them has been reduced significantly.

- ~{:bool\_col=\>true} now generates an bool\_col IS NOT TRUE filter  
instead of bool\_col != TRUE. This makes it return records with  
NULL values. If you only want to have false records, you should  
use {:bool\_col=\>false}. This works better with SQL’s 3 valued  
boolean logic.

- Model.use\_transactions was added for setting whether model objects  
should use transactions when destroying or saving records. Like  
most Sequel options, it’s settable on a global, per model, and  
per object basis:

- The Oracle adapter now supports schema parsing.

- When using Model.db=, all current dataset options are copied to  
a new dataset created with the new db.

- Model::Errors#count was refactored to improve performance.

- Most exception classes that were located under Sequel::Error are  
now located directly under Sequel. The old names are not  
deprecated (unless mentioned above), but their use is now  
discouraged. The exceptions have the same name except that  
Sequel::Error::PoolTimeoutError changed to Sequel::PoolTimeout.

- Dataset#where now always affects the WHERE clause. Before, it  
was just an alias of filter, so it modified the HAVING clause  
if the dataset already had a HAVING clause.

- The optimization of Model.[] introduced in 2.11.0 broke on  
databases that didn’t support LIMIT. The optimization now works  
on those databases.

- All of the the RDoc documentation was reviewed and many updates  
were made, resulting in significantly improved documentation  
quality.

- Model.def\_dataset\_method now works when the model doesn’t have an  
associated dataset, as it will add the method to a dataset  
given to set\_dataset in the future.

- Database#get and #select now take a block that is passed to  
the dataset they create.

- You can disable the use of INSERT RETURNING in the shared  
PostgreSQL adapter using disable\_insert\_returning. This is mostly  
useful if you are inserting a large number of records.

- A bug relating to aliasing columns in the JDBC adapter has been  
fixed.

- Sequel can now create and drop schema-qualified views.

- Performance of Dataset#destroy for model datasets was improved.

- The specs now run on Rspec 1.2.

- Internal dependence on the methods that Sequel adds to core  
classes has been eliminated, any internal use of methods that  
Sequel adds to the core classes is now considered a bug.

- A possible bug where Database#rename\_table would not remove a  
cached schema entry has been fixed.

- The Oracle and MySQL adapters now raise an error as soon as you  
call distinct on a dataset, instead of waiting until the SQL is  
generated.

## Backwards Compatibilty

- Saving a newly inserted record in an after\_create or after\_save  
hook is no longer broken. It broke in 2.10 as a side effect of  
allowing the hook to check whether or not the record was a new  
record. The code has been changed so that a @was\_new instance  
variable will be defined to true if the record was just created.

- PostgreSQL no longer uses savepoints for nested transactions by  
default. If you want to use a savepoint, you have to pass the  
:savepoint option to the transaction method. Using savepoints  
by default broke expectations when a method raised Rollback to  
rollback the transaction, and it only rolled back to the last  
savepoint.

- The anonymous model classes created by Sequel::Model() are now  
stored in Model::ANONYMOUS\_MODEL\_CLASSES instead of the @models  
class instance variable of the main module.

- The mappings of adapter schemes to classes are now stored in  
Sequel::ADAPTER\_MAP instead of the Database @@adapters class  
variable.

- Model instances no longer contain a reference to their class’s  
@db\_schema.

- Database schema sql methods (e.g. alter\_table\_sql) are now private.

- Database#[] no longer accepts a block. It’s not possible to call  
it with a block in general usage, anyway.

- The Sequel::Schema::SQL module no longer exists, the methods it  
included were placed directly in the Sequel::Database class.

- The Sequel::SQL::SpecificExpression class has been removed,  
subclasses now inherit from Sequel::SQL::Expression.

- Sequel now requires its own files with an absolute path.

- The file hierarchy of the sequel library changed significantly.

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