Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add Sequel 4.x support #333

Open
voxik opened this Issue · 2 comments

2 participants

@voxik

Sequel support is not compatible with Sequel 4.x:

  1) Sequel::Dataset::Pagination extension pagination should imitate WillPaginate::Collection
     Failure/Error: result = Car.paginate(1, 2)
     NoMethodError:
       undefined method `paginate' for #<Sequel::SQLite::Dataset: "SELECT * FROM `cars`">
     # ./spec/finders/sequel_spec.rb:34:in `block (3 levels) in <top (required)>'
  2) Sequel::Dataset::Pagination extension pagination should perform
     Failure/Error: Car.paginate(1, 2).all.should == [Car[1], Car[2]]
     NoMethodError:
       undefined method `paginate' for #<Sequel::SQLite::Dataset: "SELECT * FROM `cars`">
     # ./spec/finders/sequel_spec.rb:46:in `block (3 levels) in <top (required)>'
  3) Sequel::Dataset::Pagination extension pagination should be empty
     Failure/Error: result = Car.paginate(3, 2)
     NoMethodError:
       undefined method `paginate' for #<Sequel::SQLite::Dataset: "SELECT * FROM `cars`">
     # ./spec/finders/sequel_spec.rb:50:in `block (3 levels) in <top (required)>'
  4) Sequel::Dataset::Pagination extension pagination should perform with #select and #order
     Failure/Error: result = Car.select("name as foo".lit).order(:name).paginate(1, 2).all
     NoMethodError:
       undefined method `lit' for "name as foo":String
     # ./spec/finders/sequel_spec.rb:55:in `block (3 levels) in <top (required)>'
  5) Sequel::Dataset::Pagination extension pagination should perform with #filter
     Failure/Error: results = Car.filter(:name => 'Shelby').paginate(1, 2).all
     NoMethodError:
       undefined method `paginate' for #<Sequel::SQLite::Dataset:0x0000000304b340>
     # ./spec/finders/sequel_spec.rb:61:in `block (3 levels) in <top (required)>'

It seems there were done some structural changes in Sequel code: jeremyevans/sequel@3.48.0...4.1.1#diff-101

@russellsilva

I was able to get this working by:

  • adding require 'will_paginate/sequel' to my application.rb
  • using scope.extension(:pagination).paginate(page_number, per_page) instead of scope.paginate(page: page, per_page: per_page) in my controller

This uses the built in Sequel pagination extension, with will_paginate just being used for the view code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.