S
Sharon Rosner
Sequel version 0.4.1 has just been released. This release includes a
new plugin system for models, new experimental adapters, and
enhancements to Sequel models.
Sequel is a lightweight database access and ORM library for Ruby.
Sequel provides thread safety, connection pooling and a simple and
expressive API for constructing database queries and table schemas.
Following is a discussion of the changes.
=== Plugins for Sequel models
New in this release is as plugin system for enhancing model classes
with common functionality. Plugins are automatically loaded when used
in a model class, and enhance the model class with instance, class and
dataset methods.
The first plugin for Sequel is orderable, which allows model instances
to be part of an ordered list, based on a 'position' field in the
database. Basic usage is as follows:
class Item < Sequel::Modelitems)
is rderable
end
You can also specify the field used for determining the position by
specifying a :field option:
class Item < Sequel::Modelitems)
is rderable, :field => :my_pos_field
end
The orderable plugin is installed as a separate gem:
sudo gem install sequel_orderable
More plugins are currently being developed, including: accountable,
dequeue, linked_list, poset, queue, searchable, stack, taggable, tree
and versioned.
=== Experimental JDBC adapter
New in this release is an experimental adapter for JDBC, which might
prove useful for JRuby users. Since JDBC requires explicit loading of
drivers and has its own conventions for connection strings, connecting
to a database is a bit different than other Sequel adapters:
require 'sequel'
require 'sequel/adapters/jdbc'
Sequel::JDBC.load_driver("com.mysql.jdbc.Driver")
DB = Sequel.jdbc("mysql://127.0.0.1:3306/mydb?user=root")
The JDBC adapter will probably need more work, so feedback would be
greatly appreciated.
=== Improvements to Sequel models
Model instances now keep track of changes to field values, provided
values are changed using the attribute writer methods, or through
Model#[]= calls. Changes can be tracked by calling
Model#changed_columns:
item = Item.first
item.changed_columns #=> []
item.category = 'ruby'
item.changed_columns #=> [:category]
Changes can be saved by calling Model#save_changes:
item.category = 'sequel'
item.save_changes # will update the category field only
Also, the Model#save method can now accept a list of specific fields
to save, e.g.:
item.savecategory, :name)
=== Miscellanea
* Implemented experimental OpenBase adapter.
* Implemented odbc-mssql adapter (thanks Dusty.) This adapter offers
support for limiting the number of records selected and using NO LOCK
with MSSQL databases.
* Fixed Sequel.<xxx> methods to accept options hash as well as
database name. Fixed Sequel.connect to accept options hash as well as
URI.
* Fixed #first and #last functionality in Informix:ataset (thanks
Gerardo Santana).
=== More info
Sequel project page:
<http://code.google.com/p/ruby-sequel>
Sequel documentation:
<http://sequel.rubyforge.org>
Join the Sequel-talk group:
<http://groups.google.com/group/sequel-talk>
Install the gem:
sudo gem install sequel
Or check out the source and install manually:
svn co http://ruby-sequel.googlecode.com/svn/trunk sequel
cd sequel
rake install
new plugin system for models, new experimental adapters, and
enhancements to Sequel models.
Sequel is a lightweight database access and ORM library for Ruby.
Sequel provides thread safety, connection pooling and a simple and
expressive API for constructing database queries and table schemas.
Following is a discussion of the changes.
=== Plugins for Sequel models
New in this release is as plugin system for enhancing model classes
with common functionality. Plugins are automatically loaded when used
in a model class, and enhance the model class with instance, class and
dataset methods.
The first plugin for Sequel is orderable, which allows model instances
to be part of an ordered list, based on a 'position' field in the
database. Basic usage is as follows:
class Item < Sequel::Modelitems)
is rderable
end
You can also specify the field used for determining the position by
specifying a :field option:
class Item < Sequel::Modelitems)
is rderable, :field => :my_pos_field
end
The orderable plugin is installed as a separate gem:
sudo gem install sequel_orderable
More plugins are currently being developed, including: accountable,
dequeue, linked_list, poset, queue, searchable, stack, taggable, tree
and versioned.
=== Experimental JDBC adapter
New in this release is an experimental adapter for JDBC, which might
prove useful for JRuby users. Since JDBC requires explicit loading of
drivers and has its own conventions for connection strings, connecting
to a database is a bit different than other Sequel adapters:
require 'sequel'
require 'sequel/adapters/jdbc'
Sequel::JDBC.load_driver("com.mysql.jdbc.Driver")
DB = Sequel.jdbc("mysql://127.0.0.1:3306/mydb?user=root")
The JDBC adapter will probably need more work, so feedback would be
greatly appreciated.
=== Improvements to Sequel models
Model instances now keep track of changes to field values, provided
values are changed using the attribute writer methods, or through
Model#[]= calls. Changes can be tracked by calling
Model#changed_columns:
item = Item.first
item.changed_columns #=> []
item.category = 'ruby'
item.changed_columns #=> [:category]
Changes can be saved by calling Model#save_changes:
item.category = 'sequel'
item.save_changes # will update the category field only
Also, the Model#save method can now accept a list of specific fields
to save, e.g.:
item.savecategory, :name)
=== Miscellanea
* Implemented experimental OpenBase adapter.
* Implemented odbc-mssql adapter (thanks Dusty.) This adapter offers
support for limiting the number of records selected and using NO LOCK
with MSSQL databases.
* Fixed Sequel.<xxx> methods to accept options hash as well as
database name. Fixed Sequel.connect to accept options hash as well as
URI.
* Fixed #first and #last functionality in Informix:ataset (thanks
Gerardo Santana).
=== More info
Sequel project page:
<http://code.google.com/p/ruby-sequel>
Sequel documentation:
<http://sequel.rubyforge.org>
Join the Sequel-talk group:
<http://groups.google.com/group/sequel-talk>
Install the gem:
sudo gem install sequel
Or check out the source and install manually:
svn co http://ruby-sequel.googlecode.com/svn/trunk sequel
cd sequel
rake install