Created
March 19, 2009 05:21
-
-
Save jmettraux/81608 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(limit only) setlimit(2, 0) --> 2 rows | |
(limit only) setlimit(2, 1) --> 2 rows | |
(limit only) setlimit(2, 2) --> 2 rows | |
(limit only) setlimit(2, 3) --> 2 rows | |
(limit only) setlimit(2, 4) --> 1 rows | |
(order and limit) setlimit(2, 0) --> 2 rows | |
(order and limit) setlimit(2, 1) --> 3 rows | |
(order and limit) setlimit(2, 2) --> 3 rows | |
(order and limit) setlimit(2, 3) --> 2 rows | |
(order and limit) setlimit(2, 4) --> 1 rows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# issue with setlimit(max, skip) | |
# | |
# | |
# sudo gem install rufus-tokyo | |
# | |
require 'rubygems' | |
require 'rufus/tokyo' | |
t = Rufus::Tokyo::Table.new('table.tct') | |
t['pk0'] = { 'name' => 'alfred', 'age' => '22' } | |
t['pk1'] = { 'name' => 'bob', 'age' => '18' } | |
t['pk2'] = { 'name' => 'charly', 'age' => '45' } | |
t['pk3'] = { 'name' => 'doug', 'age' => '77' } | |
t['pk4'] = { 'name' => 'ephrem', 'age' => '32' } | |
MAX = 2 | |
puts | |
5.times do |i| | |
count = t.query { |q| q.limit MAX, i }.size | |
puts " (limit only) setlimit(#{MAX}, #{i}) --> #{count} rows" | |
end | |
puts | |
5.times do |i| | |
count = t.query { |q| | |
q.order_by 'name', :desc | |
q.limit MAX, i | |
}.size | |
puts " (order and limit) setlimit(#{MAX}, #{i}) --> #{count} rows" | |
end | |
t.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment