activerecord-filter 5.0.0.1 → 5.0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_record/filter.rb +4 -2
- data/lib/active_record/filter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68bc3dfb112ded5ee45418075110ef888aba01a5
|
4
|
+
data.tar.gz: 73407b0438f5a6f71c9f8b3d9c2a4f83d60c778e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9b0b4704b1700f97feb2697d2d0ccb6e32aeb9576f1b2aed4735627f4ccb7a9197706031e07fe547205f3c8e47ac1c4eb73e3dddfc97834607072b0cafffbf3
|
7
|
+
data.tar.gz: 71dcd0b33b1d4d2dc17dd15eb00cf8eaf0bb29a5f35d77da8fbe7858d9368aa400d08255afed643522a87cc1926e441765fa7fa4915c0ce0a3bee16a71999e72
|
data/lib/active_record/filter.rb
CHANGED
@@ -40,7 +40,7 @@ module ActiveRecord::Filter
|
|
40
40
|
|
41
41
|
def filter_for(key, value, options={})
|
42
42
|
column = columns_hash[key.to_s]
|
43
|
-
|
43
|
+
|
44
44
|
if column && column.array
|
45
45
|
all.filter_for_array(key, value, options)
|
46
46
|
elsif column
|
@@ -137,6 +137,8 @@ module ActiveRecord::Filter
|
|
137
137
|
when :filter_for_boolean then where(table[column].eq(value.try(:send, send_method)))
|
138
138
|
else where(table[column].eq(nil))
|
139
139
|
end
|
140
|
+
elsif value == nil
|
141
|
+
where(table[column].eq(value).or(table[column].eq(nil)))
|
140
142
|
# when ''
|
141
143
|
# # TODO support nil. Currently rails params encode nil as empty strings,
|
142
144
|
# # and we can't tell which is desired, so do both
|
@@ -225,7 +227,7 @@ module ActiveRecord::Filter
|
|
225
227
|
elsif resource.klass == relation.klass
|
226
228
|
options[:table_alias] = "#{relation.name}_#{relation.klass.table_name}"
|
227
229
|
end
|
228
|
-
|
230
|
+
|
229
231
|
if value.is_a?(Hash) || value.class.name == "ActionController::Parameters".freeze
|
230
232
|
resource = resource.joins(relation.name) #if !resource.references?(relation.name)
|
231
233
|
resource = resource.merge(relation.klass.filter(value, options))
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.0.
|
4
|
+
version: 5.0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Bracy
|
@@ -242,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
242
242
|
version: '0'
|
243
243
|
requirements: []
|
244
244
|
rubyforge_project:
|
245
|
-
rubygems_version: 2.
|
245
|
+
rubygems_version: 2.5.1
|
246
246
|
signing_key:
|
247
247
|
specification_version: 4
|
248
248
|
summary: A safe way to accept user parameters and query against your ActiveRecord
|