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 +4 -4
- data/lib/active_record/filter.rb +14 -10
- 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: 0891c91632adac443eea01685d08f599c16b61f0
|
4
|
+
data.tar.gz: 893066947ef4c7ece89f7e7a613d2a51cd272bae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27671c1a861dceecdb5c466d49bbcf9dd940cd9c892ede60e7444b322dadabfe35a838d6a2bf06b867eee16a32466dd979f790ccb9e30fc69c4b5a434bc89e96
|
7
|
+
data.tar.gz: 14ebd489fac3b544474b00c0e5ea8a12e9ac2a06d16b75856531b6eba3eec86e158bf812e122373c636a8d37eb82a41247ceaa793324b641ff8360de4044c9a1
|
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
|
@@ -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
|
163
|
-
|
164
|
-
|
165
|
-
|
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))
|
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.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-
|
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.
|
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
|