S
Sharon Rosner
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
=3D=3D=3D=3D=3D=3D=3D=3D=3D
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 =3D Recipe.filter('body LIKE ?',
params[:search]).paginate(params[
age], params[
age_size])
end
What you get back from #paginate is just a regular dataset, but with
the following methods:
@recipes.page_count #=3D> the total number of pages available
@recipes.current_page #=3D> the current page number
@recipes.prev_page #=3D> the previous page number or nil if we're on
the first page
@recipes.next_page #=3D> the next page number or nil if we're on the
last page
Dataset#[]=3D for updating records
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
New shorthand for conditional UPDATEs. Instead of:
items.filter
group_id =3D> 29).update
stamp =3D> Time.now)
You can now write:
items[:group_id =3D> 29] =3D {:stamp =3D> Time.now}
More concise first and last calls
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D
Dataset#first and Dataset#last now accept hashes for specifying
filters, so now you can drop the filter call. Instead of:
people.filter
name =3D> 'sharon').first
You can now write:
items.first
name =3D> 'sharon')
More concise opening of databases
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D
Sequel now defines a Sequel method call, so instead of:
DB =3D Sequel.open 'sqlite:/'
You can now write:
DB =3D Sequel('sqlite:/')
Bug fixes
=3D=3D=3D=3D=3D=3D=3D=3D=3D
* 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=DFmann and Pedro Gutierrez).
* Fixed Symbol#DESC to support qualified notation (thanks Pedro
Gutierrez).
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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
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
=3D=3D=3D=3D=3D=3D=3D=3D=3D
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 =3D Recipe.filter('body LIKE ?',
params[:search]).paginate(params[
end
What you get back from #paginate is just a regular dataset, but with
the following methods:
@recipes.page_count #=3D> the total number of pages available
@recipes.current_page #=3D> the current page number
@recipes.prev_page #=3D> the previous page number or nil if we're on
the first page
@recipes.next_page #=3D> the next page number or nil if we're on the
last page
Dataset#[]=3D for updating records
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
New shorthand for conditional UPDATEs. Instead of:
items.filter
You can now write:
items[:group_id =3D> 29] =3D {:stamp =3D> Time.now}
More concise first and last calls
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D
Dataset#first and Dataset#last now accept hashes for specifying
filters, so now you can drop the filter call. Instead of:
people.filter
You can now write:
items.first
More concise opening of databases
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D
Sequel now defines a Sequel method call, so instead of:
DB =3D Sequel.open 'sqlite:/'
You can now write:
DB =3D Sequel('sqlite:/')
Bug fixes
=3D=3D=3D=3D=3D=3D=3D=3D=3D
* 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=DFmann and Pedro Gutierrez).
* Fixed Symbol#DESC to support qualified notation (thanks Pedro
Gutierrez).
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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