record_filter 0.9.15 → 0.9.16
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/restrictions.rb +9 -2
- data/record_filter.gemspec +2 -2
- data/spec/restrictions_spec.rb +7 -0
- data/spec/test.db +0 -0
- metadata +2 -2
data/VERSION.yml
CHANGED
@@ -90,8 +90,15 @@ module RecordFilter
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def to_conditions
|
93
|
-
#
|
94
|
-
|
93
|
+
# For NOT IN conditions, passing an empty array as the value will
|
94
|
+
# produce a condition like "WHERE id NOT IN (NULL)", and that will
|
95
|
+
# return an empty set, which is presumably not what the user meant
|
96
|
+
# to get. Doing some babysitting here.
|
97
|
+
if @negated && @value.respond_to?(:empty?) && @value.empty?
|
98
|
+
[]
|
99
|
+
else
|
100
|
+
[to_sql, @value]
|
101
|
+
end
|
95
102
|
end
|
96
103
|
end
|
97
104
|
|
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.16"
|
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{2010-
|
12
|
+
s.date = %q{2010-02-12}
|
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 = [
|
data/spec/restrictions_spec.rb
CHANGED
@@ -80,6 +80,13 @@ describe 'RecordFilter restrictions' do
|
|
80
80
|
Post.last_find.should == { :readonly => false, :conditions => [%q("posts".blog_id IN (?)), []] }
|
81
81
|
end
|
82
82
|
|
83
|
+
it 'should ignore the condition for NOT IN filters with empty arrays' do
|
84
|
+
Post.filter do
|
85
|
+
with(:blog_id).not_in([])
|
86
|
+
end.inspect
|
87
|
+
Post.last_find.should == { :readonly => false }
|
88
|
+
end
|
89
|
+
|
83
90
|
it 'should do the right thing for IN filters with single values' do
|
84
91
|
Post.filter do
|
85
92
|
with(:blog_id).in(1)
|
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.16
|
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: 2010-
|
13
|
+
date: 2010-02-12 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|