ANN: Sequel 0.1.7 Released

Sequel version 0.1.7 has just been released. This is mainly a bug fix
release, but there is also some new functionality, mainly convenience
methods, and a new pagination feature. Following is a discussion of
the main changes:

Pagination

If you’re using Sequel in an MVC setting you might find this one
useful. A new Dataset#paginate method provides a very simple
pagination interface. Here’s a contrived example:

def search
@recipes = Recipe.filter(‘body LIKE ?’,
params[:search]).paginate(params[:page], params[:page_size])
end

What you get back from #paginate is just a regular dataset, but with
the following methods:

@recipes.page_count #=> the total number of pages available
@recipes.current_page #=> the current page number
@recipes.prev_page #=> the previous page number or nil if we’re on
the first page
@recipes.next_page #=> the next page number or nil if we’re on the
last page

Dataset#[]= for updating records

New shorthand for conditional UPDATEs. Instead of:

items.filter(:group_id => 29).update(:stamp => Time.now)

You can now write:

items[:group_id => 29] = {:stamp => Time.now}

More concise first and last calls

Dataset#first and Dataset#last now accept hashes for specifying
filters, so now you can drop the filter call. Instead of:

people.filter(:name => ‘sharon’).first

You can now write:

items.first(:name => ‘sharon’)

More concise opening of databases

Sequel now defines a Sequel method call, so instead of:

DB = Sequel.open ‘sqlite:/’

You can now write:

DB = Sequel(‘sqlite:/’)

Bug fixes

  • Implemented Model.join method to restrict returned columns to the
    model table (thanks Pedro Gutierrez).

  • Fixed after_destroy hook to actually work.

  • Fixed Dataset#first to include a LIMIT clause for a single record.

  • Small fix to Postgres driver to return a primary_key value for the
    inserted record if it is specified in the insertion values (thanks
    Florian Aßmann and Pedro Gutierrez).

  • Fixed Symbol#DESC to support qualified notation (thanks Pedro
    Gutierrez).

======================

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs