record_filter 0.9.14 → 0.9.15
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/record_filter/conjunctions.rb +9 -3
- data/lib/record_filter/dsl/conjunction.rb +6 -2
- data/lib/record_filter/dsl/dsl.rb +3 -2
- data/lib/record_filter/dsl/limit.rb +3 -3
- data/lib/record_filter/dsl/offset.rb +12 -0
- data/lib/record_filter/dsl.rb +1 -1
- data/record_filter.gemspec +3 -2
- data/spec/limits_and_ordering_spec.rb +14 -0
- data/spec/test.db +0 -0
- metadata +3 -2
data/VERSION.yml
CHANGED
@@ -26,7 +26,9 @@ module RecordFilter
|
|
26
26
|
step.join_class, step.join_type, step.table_alias, step.conditions)
|
27
27
|
result.add_conjunction(create_from(step.conjunction, join.right_table))
|
28
28
|
when DSL::Limit
|
29
|
-
result.
|
29
|
+
result.add_limit(step.limit)
|
30
|
+
when DSL::Offset
|
31
|
+
result.add_offset(step.offset)
|
30
32
|
when DSL::Order
|
31
33
|
result.add_order(step.column, step.direction)
|
32
34
|
when DSL::GroupBy
|
@@ -80,8 +82,12 @@ module RecordFilter
|
|
80
82
|
@table.group_by_column(column_name)
|
81
83
|
end
|
82
84
|
|
83
|
-
def
|
84
|
-
@limit
|
85
|
+
def add_limit(limit)
|
86
|
+
@limit = limit
|
87
|
+
end
|
88
|
+
|
89
|
+
def add_offset(offset)
|
90
|
+
@offset = offset
|
85
91
|
end
|
86
92
|
|
87
93
|
def set_distinct(value)
|
@@ -33,8 +33,12 @@ module RecordFilter
|
|
33
33
|
dsl
|
34
34
|
end
|
35
35
|
|
36
|
-
def add_limit(limit
|
37
|
-
@steps << Limit.new(limit
|
36
|
+
def add_limit(limit)
|
37
|
+
@steps << Limit.new(limit)
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_offset(offset)
|
41
|
+
@steps << Offset.new(offset)
|
38
42
|
end
|
39
43
|
|
40
44
|
def add_order(column, direction)
|
@@ -19,7 +19,8 @@ module RecordFilter
|
|
19
19
|
#
|
20
20
|
# @public
|
21
21
|
def limit(limit, offset=nil)
|
22
|
-
@conjunction.add_limit(limit
|
22
|
+
@conjunction.add_limit(limit)
|
23
|
+
@conjunction.add_offset(offset) if offset
|
23
24
|
nil
|
24
25
|
end
|
25
26
|
|
@@ -37,7 +38,7 @@ module RecordFilter
|
|
37
38
|
#
|
38
39
|
# @public
|
39
40
|
def offset(offset)
|
40
|
-
@conjunction.
|
41
|
+
@conjunction.add_offset(offset)
|
41
42
|
nil
|
42
43
|
end
|
43
44
|
|
data/lib/record_filter/dsl.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
%w(class_join conjunction conjunction_dsl dsl dsl_factory group_by join join_dsl join_condition limit named_filter order restriction).each { |file| require File.join(File.dirname(__FILE__), 'dsl', file) }
|
1
|
+
%w(class_join conjunction conjunction_dsl dsl dsl_factory group_by join join_dsl join_condition limit named_filter offset order restriction).each { |file| require File.join(File.dirname(__FILE__), 'dsl', file) }
|
2
2
|
|
3
3
|
module RecordFilter
|
4
4
|
# The DSL module defines the structure of the criteria API used in calls to
|
data/record_filter.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{record_filter}
|
8
|
-
s.version = "0.9.
|
8
|
+
s.version = "0.9.15"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Aubrey Holland", "Mat Brown"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2010-01-04}
|
13
13
|
s.description = %q{RecordFilter is a Pure-ruby criteria API for building complex queries in ActiveRecord. It supports queries that are built on the fly as well as named filters that can be added to objects and chained to create complex queries. It also gets rid of the nasty hard-coded SQL that shows up in most ActiveRecord code with a clean API that makes queries simple and intuitive to build.}
|
14
14
|
s.email = %q{aubreyholland@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -39,6 +39,7 @@ Gem::Specification.new do |s|
|
|
39
39
|
"lib/record_filter/dsl/join_dsl.rb",
|
40
40
|
"lib/record_filter/dsl/limit.rb",
|
41
41
|
"lib/record_filter/dsl/named_filter.rb",
|
42
|
+
"lib/record_filter/dsl/offset.rb",
|
42
43
|
"lib/record_filter/dsl/order.rb",
|
43
44
|
"lib/record_filter/dsl/restriction.rb",
|
44
45
|
"lib/record_filter/filter.rb",
|
@@ -91,6 +91,20 @@ describe 'filter qualifiers' do
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
+
describe 'with both a limit and an offset' do
|
95
|
+
before do
|
96
|
+
Post.filter do
|
97
|
+
limit(10)
|
98
|
+
offset(8)
|
99
|
+
end.inspect
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should add the limit and offset to the parameters' do
|
103
|
+
Post.last_find[:offset].should == 8
|
104
|
+
Post.last_find[:limit].should == 10
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
94
108
|
describe 'offsetting named scopes' do
|
95
109
|
before do
|
96
110
|
@post = Class.new(Post)
|
data/spec/test.db
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: record_filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aubrey Holland
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
13
|
+
date: 2010-01-04 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- lib/record_filter/dsl/join_dsl.rb
|
66
66
|
- lib/record_filter/dsl/limit.rb
|
67
67
|
- lib/record_filter/dsl/named_filter.rb
|
68
|
+
- lib/record_filter/dsl/offset.rb
|
68
69
|
- lib/record_filter/dsl/order.rb
|
69
70
|
- lib/record_filter/dsl/restriction.rb
|
70
71
|
- lib/record_filter/filter.rb
|