Add Sequel 4.x support #333

Open
voxik opened this Issue Aug 21, 2013 · 2 comments

Comments

Projects
None yet
2 participants
@voxik

voxik commented Aug 21, 2013

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.1diff-101

@russellsilva

This comment has been minimized.

Show comment Hide comment
@russellsilva

russellsilva Jul 28, 2014

👍

👍

@russellsilva

This comment has been minimized.

Show comment Hide comment
@russellsilva

russellsilva Jul 29, 2014

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.

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.

chen7897499 added a commit to chen7897499/simple-image-gallery that referenced this issue Feb 17, 2016

添加分页
因为wi_paginate暂时不能完美支持sequel, 所以现在只能通过array来分页
mislav/will_paginate#333
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment