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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1fe442ec2d9469a50ef10c77bb05d728407be95
4
- data.tar.gz: d6670cedb256f494a36d7af5ffa2a582398ffd16
3
+ metadata.gz: 68bc3dfb112ded5ee45418075110ef888aba01a5
4
+ data.tar.gz: 73407b0438f5a6f71c9f8b3d9c2a4f83d60c778e
5
5
  SHA512:
6
- metadata.gz: c42f5aab8ec42ea638761946ba345e2b79900c426b8fec9d794cb2715c787ce3792db73229529656bdafe6e9141e4266dd05187be38bdd040582218638e49eb4
7
- data.tar.gz: 459451d4a977fcf775047da9677ddf9011f88572436ac15d81f48044e6856ec0de832d32179a71a8f4d5783258f112053c3977739e230c9a7d5ca42a66ed4052
6
+ metadata.gz: b9b0b4704b1700f97feb2697d2d0ccb6e32aeb9576f1b2aed4735627f4ccb7a9197706031e07fe547205f3c8e47ac1c4eb73e3dddfc97834607072b0cafffbf3
7
+ data.tar.gz: 71dcd0b33b1d4d2dc17dd15eb00cf8eaf0bb29a5f35d77da8fbe7858d9368aa400d08255afed643522a87cc1926e441765fa7fa4915c0ce0a3bee16a71999e72
@@ -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))
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Filter
3
- VERSION = '5.0.0.1'
3
+ VERSION = '5.0.0.2'
4
4
  end
5
5
  end
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.1
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.6.4
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