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

Optimizations
-------------

* Model.[] was optimized to use static SQL in cases where doing so
should result in the same output. This should result in a 30-40%
performance increase. Since this can be the most significant or
only method call in a web application action, this has potential
to significantly enhance the performance of web application code.

In order for this optimization to have an effect, you need to
make sure that you are calling set_dataset with a Symbol and
not a Dataset object:

* Dataset#literal was refactored for performance reasons to make
overriding it in subclasses unnecessary. The changes made result
in a 20-25% performance increase. Sequel can spend about 10% of
it's time in Dataset#literal, so this may be only a 2% overall
performance improvement.

New Features
------------

* Association datasets now know about the model objects that created
them, as well as the related association reflection. This makes
association extensions much more powerful. For example, you can
now create generic association extensions such as:

* A :clone association option was added, which allows you to clone
an existing association. This is most useful when you are dealing
with a legacy schema and had to define the same options redundantly
for each type of association. You can now do:

All of the above would use the same :class, :join_table, :left_key,
:right_key, and rder options. If you don't provide an
association block, but you are cloning an association that has one,
the cloned association's block is used. You can use the
:block=>nil option to not use a block even if the cloned
association has a block.

* Dataset#select, #select_more, #order, #order_more, and #get all
take a block that yields a Sequel::SQL::VirtualRow instance,
similar to the behavior of filter. This allows for the easier
use of SQL functions on Ruby 1.9:

* String#lit can now accept arguments and return an SQL literal
string. This allows you to do things that were previously hard
or at least unnecessarily verbose. For example, you can now
easily use the SQL standard SUBSTRING function:

* Dataset#with_sql was added, which returns a copy of the dataset
with static SQL. This is useful if you want to keep the same
row_proc/graph/transform/etc., but want to use your own custom
SQL.

Other Improvements
------------------

* You can now use Sequel's database independent types when casting:

dataset.selectnumber.cast(String))

Among other things, the default cast types for cast_string and
cast_numeric now work in the MySQL adapter.

* Model#set_associated_object was added. The many_to_one association
setter method calls it. This allows you to easily override the
association setters for all many_to_one associations of a class
by modifying a single method.

* Typecasting invalid date strings now raises a
Sequel::Error::InvalidValue instead of an argument error, which
means that you can use raise_on_typecast_failure = false and not
have an error raised when an invalid date format is used.

* String#to_sequel_blob was added and should now be used instead
of String#to_blob. sqlite3-ruby defines String#to_blob
differently, which could cause problems.

* Blob columns are now fully supported in the SQLite adapter, with
the hex escape syntax being used for input, and returning columns
of type Sequel::SQL::Blob on output.

* The SQLite adapter drop_column support is now significantly more
robust.

* The optimization of Model.[] may break if you modify the model's
dataset behind its back. Always use Model.set_dataset if you
want to change a Model's dataset.

* Sequel:ataset::UnsupportedExceptIntersect and
Sequel:ataset::UnsupportedExceptIntersectAll will now only be
defined if you are using an adapter that requires them.

* The private Model#cache_delete_unless_new method has been removed.

* Sequel::SQL::IrregularFunction was removed, as it was a bad hack
that is not used by Sequel anymore. Unless you were instantiating
it directly or using a plugin/extension that did, this shouldn't
affect you. Using a Sequel::SQL::Function with a
Sequel::SQL:laceholderLiteralString is recommended instead, see
the substring example above.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!