activerecord-filter 5.0.0.5 → 5.0.0.6

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: 0891c91632adac443eea01685d08f599c16b61f0
4
- data.tar.gz: 893066947ef4c7ece89f7e7a613d2a51cd272bae
3
+ metadata.gz: 7ebd77f99aa6b3919c780144570afccb9020e970
4
+ data.tar.gz: 9bb379f8e4148ca004c7b5823efcb56b95b2c952
5
5
  SHA512:
6
- metadata.gz: 27671c1a861dceecdb5c466d49bbcf9dd940cd9c892ede60e7444b322dadabfe35a838d6a2bf06b867eee16a32466dd979f790ccb9e30fc69c4b5a434bc89e96
7
- data.tar.gz: 14ebd489fac3b544474b00c0e5ea8a12e9ac2a06d16b75856531b6eba3eec86e158bf812e122373c636a8d37eb82a41247ceaa793324b641ff8360de4044c9a1
6
+ metadata.gz: cafc7b16939a790e9a134e0a7266f14424ab1e9f5d18543c7edf1f7437254592b48c68bd0f85ccb87aee55eb03ad27ea4b24f252223b6ee617747beed216430d
7
+ data.tar.gz: f128d2aee5a42cdbb6c4f6dea4f772aaf30f7bfae9f407b0d60a950bf56fdb347389049e2adc7858734d919b0fd366bc00b2ee2e2d354c9c92f080867564940a
@@ -92,7 +92,7 @@ module ActiveRecord::Filter
92
92
  when :not
93
93
  resource.where(table[column].not_eq(converted_value))
94
94
  when :not_in
95
- resource.where(table[column].not_in(converted_value).or(table[column].eq(nil)))
95
+ resource.where(table[column].not_in(converted_value))
96
96
  when :like, :ilike
97
97
  resource.where(table[column].matches(converted_value))
98
98
  when :ts_match
@@ -188,7 +188,7 @@ module ActiveRecord::Filter
188
188
  when :has_key
189
189
  resource.where(column.has_key(value))
190
190
  when :not_in
191
- resource.where(column.not_in(value).or(column.eq(nil)))
191
+ resource.where(column.not_in(value))
192
192
  else
193
193
  raise 'Not supported'
194
194
  end
@@ -285,6 +285,11 @@ module ActiveRecord::Filter
285
285
 
286
286
  def filter_for_belongs_to(relation, value)
287
287
  resource = all
288
+
289
+ options = {}
290
+ if connection.class.name == 'ActiveRecord::ConnectionAdapters::SunstoneAPIAdapter'
291
+ options[:table_alias] = relation.name
292
+ end
288
293
 
289
294
  if value.is_a?(Array) || value.is_a?(Integer) || value.is_a?(NilClass)
290
295
  resource = resource.where(:"#{relation.foreign_key}" => value)
@@ -302,10 +307,10 @@ module ActiveRecord::Filter
302
307
  resource = resource.joins(t1.join(t2).on(
303
308
  t2[:id].eq(t1["#{relation.name}_id"]).and(t1["#{relation.name}_type"].eq(klass.name))
304
309
  ).join_sources.first)
305
- resource = resource.merge(klass.filter(v))
310
+ resource = resource.merge(klass.filter(v, options))
306
311
  else
307
312
  resource = resource.joins(relation.name) # if !resource.references?(relation.name)
308
- resource = resource.merge(relation.klass.filter(value))
313
+ resource = resource.merge(relation.klass.filter(value, options))
309
314
  end
310
315
  else
311
316
  if value.is_a?(String) && value =~ /\A\d+\Z/
@@ -319,4 +324,4 @@ module ActiveRecord::Filter
319
324
 
320
325
  end
321
326
 
322
- ActiveRecord::Base.extend(ActiveRecord::Filter)
327
+ ActiveRecord::Base.extend(ActiveRecord::Filter)
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Filter
3
- VERSION = '5.0.0.5'
3
+ VERSION = '5.0.0.6'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.5
4
+ version: 5.0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Bracy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-06 00:00:00.000000000 Z
11
+ date: 2017-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -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.6.8
246
246
  signing_key:
247
247
  specification_version: 4
248
248
  summary: A safe way to accept user parameters and query against your ActiveRecord