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 +4 -4
- data/lib/active_record/filter.rb +10 -5
- data/lib/active_record/filter/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ebd77f99aa6b3919c780144570afccb9020e970
|
4
|
+
data.tar.gz: 9bb379f8e4148ca004c7b5823efcb56b95b2c952
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cafc7b16939a790e9a134e0a7266f14424ab1e9f5d18543c7edf1f7437254592b48c68bd0f85ccb87aee55eb03ad27ea4b24f252223b6ee617747beed216430d
|
7
|
+
data.tar.gz: f128d2aee5a42cdbb6c4f6dea4f772aaf30f7bfae9f407b0d60a950bf56fdb347389049e2adc7858734d919b0fd366bc00b2ee2e2d354c9c92f080867564940a
|
data/lib/active_record/filter.rb
CHANGED
@@ -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)
|
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)
|
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)
|
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.
|
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:
|
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.
|
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
|