activerecord-filter 5.0.0.3 → 5.0.0.5

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: c84e49f9cc530782e0526995e700902d7937fb7f
4
- data.tar.gz: 1414458d78e798480fea0f2e0970e7a31b259597
3
+ metadata.gz: 0891c91632adac443eea01685d08f599c16b61f0
4
+ data.tar.gz: 893066947ef4c7ece89f7e7a613d2a51cd272bae
5
5
  SHA512:
6
- metadata.gz: 90af8fd5f4e3fc6466ff416152e9141b920304f3f9b68f0b414b0326e5945ecbf575cde92a816079b9638f2ce8217325ae29f36e703296ff3128ae40e8747cb7
7
- data.tar.gz: a12596a64b36cce8e3e4fbe92c13d74ca423b17da86a2860212befe3f08fbd2d720b52659b2611d2b49c656cd5cfea168fa6e10af5c2c8dbb7c9eee2b2cdb06d
6
+ metadata.gz: 27671c1a861dceecdb5c466d49bbcf9dd940cd9c892ede60e7444b322dadabfe35a838d6a2bf06b867eee16a32466dd979f790ccb9e30fc69c4b5a434bc89e96
7
+ data.tar.gz: 14ebd489fac3b544474b00c0e5ea8a12e9ac2a06d16b75856531b6eba3eec86e158bf812e122373c636a8d37eb82a41247ceaa793324b641ff8360de4044c9a1
@@ -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
@@ -155,19 +155,23 @@ module ActiveRecord::Filter
155
155
  table = options[:table_alias] ? arel_table.alias(options[:table_alias]) : arel_table
156
156
  column = table[column]
157
157
 
158
- drill_for_json(column, value, all)
158
+ drill_for_json(column, value, all, 'jsonb')
159
159
  end
160
- alias :filter_for_json :filter_for_jsonb
161
160
 
162
- def drill_for_json(column, drill, resource)
163
- if cast = drill.delete(:cast)
164
- column = column.cast_as(cast)
165
- end
166
-
161
+ def filter_for_json(column, value, options = {})
162
+ table = options[:table_alias] ? arel_table.alias(options[:table_alias]) : arel_table
163
+ column = table[column]
164
+
165
+ drill_for_json(column, value, all, 'json')
166
+ end
167
+
168
+ def drill_for_json(column, drill, resource, cast)
167
169
  drill.each do |key, value|
168
170
  if value.is_a?(Hash) || value.class.name == "ActionController::Parameters".freeze
169
- resource = drill_for_json(column.key(key), value, resource)
171
+ resource = drill_for_json(column.key(key), value, resource, cast)
170
172
  else
173
+ value = Arel::Attributes::Cast.new(Arel::Nodes::Quoted.new(value.to_s), cast)
174
+
171
175
  resource = case key.to_sym
172
176
  when :equal, :eq
173
177
  resource.where(column.eq(value))
@@ -227,7 +231,7 @@ module ActiveRecord::Filter
227
231
  elsif resource.klass == relation.klass
228
232
  options[:table_alias] = "#{relation.name}_#{relation.klass.table_name}"
229
233
  end
230
-
234
+
231
235
  if value.is_a?(Hash) || value.class.name == "ActionController::Parameters".freeze
232
236
  resource = resource.joins(relation.name) #if !resource.references?(relation.name)
233
237
  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.3'
3
+ VERSION = '5.0.0.5'
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.3
4
+ version: 5.0.0.5
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-09-02 00:00:00.000000000 Z
11
+ date: 2016-10-06 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.5.1
245
+ rubygems_version: 2.6.4
246
246
  signing_key:
247
247
  specification_version: 4
248
248
  summary: A safe way to accept user parameters and query against your ActiveRecord