0

I have a big horrible query that is built in lots of terrible steps (The problems with working with legacy databases.) which I would like to add pagination to. I had hoped to sidestep writing a custom result (I can't figure out how to get the total without executing a separate query).

I had hoped to use Sequels inbuild pagination to do this or [the will_paginate gem](but I can't seem to get either to work, can it be used on general queries of the form

I have tried both:

DB["select some really long ugly sql"].pagination_record_count

and

DB["select some really long ugly sql"].paginate(1, 10)

with

require 'sequel/extensions/pagination'
DB.extension(:pagination)

from here for the first example. and

require 'will_paginate'
require 'will_paginate/active_record'

along with trying

require 'will_paginate/collection'
require 'will_paginate/version'
require 'sequel/extensions/pagination'

None of these seem to work, will it just not work for normal sequel queries? Is there something I'm missing?

Does anyone have any other advice on implementing pagination (like how to get things to happen in one request?)

Thanks in advance.

Mike H-R
  • 7,726
  • 5
  • 43
  • 65
  • Upfront: I don't know Sequel. I know SQL and ansi-sql and I refer to (select some really long ugly sql). When you use MSSQL, in the case of long queries, if you end up selecting lots of things during the query, the resultant application does not know which "result" you want a count from. In that case, you use SET NOCOUNT ON to avoid that. This may be the case too. Hope it helps. – Anthony Horne Apr 17 '14 at 11:13
  • thanks @AnthonyHorne I'll read up on that. – Mike H-R Apr 17 '14 at 11:14

0 Answers0