pattern_query_helper 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/lib/pattern_query_helper/filtering.rb +14 -3
- data/lib/pattern_query_helper/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c3503df41d4640984dac6772f15d439c23b8fd3904514d58fb98b2af7efbc45
|
4
|
+
data.tar.gz: d40370dd2f2e9c2da4b0993a7ac21d08dbc512b76bd2da031ff1e3ce56605507
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30a723aca45d1ceb20f914826367ca92bfc6381ebe621d823163c0cc3eb6615b4398dc1e4147f4dad4b40b41c8c71bb52191ab8909d384b6ff345caf1982f224
|
7
|
+
data.tar.gz: 8c8c2855b31e831ed3b22c6c1f2709e15f2ee332515becf48e8a31637a82cf1ded7712155444d89e740bde76a0f62f53a765e61b4686930870507c755e63e8a7
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pattern_query_helper (0.2.
|
4
|
+
pattern_query_helper (0.2.6)
|
5
5
|
activerecord (~> 5.0)
|
6
6
|
kaminari (~> 1.1.1)
|
7
7
|
|
@@ -53,7 +53,7 @@ GEM
|
|
53
53
|
nokogiri (>= 1.5.9)
|
54
54
|
mini_portile2 (2.4.0)
|
55
55
|
minitest (5.11.3)
|
56
|
-
nokogiri (1.10.
|
56
|
+
nokogiri (1.10.3)
|
57
57
|
mini_portile2 (~> 2.4.0)
|
58
58
|
rails-dom-testing (2.0.3)
|
59
59
|
activesupport (>= 4.2.0)
|
@@ -92,4 +92,4 @@ DEPENDENCIES
|
|
92
92
|
sqlite3 (~> 1.3.6)
|
93
93
|
|
94
94
|
BUNDLED WITH
|
95
|
-
1.
|
95
|
+
1.17.3
|
@@ -25,14 +25,24 @@ module PatternQueryHelper
|
|
25
25
|
when "noteql"
|
26
26
|
operator = "!="
|
27
27
|
when "like"
|
28
|
+
modified_filter_attribute = "lower(#{filter_attribute})"
|
28
29
|
operator = "like"
|
30
|
+
criterion.downcase!
|
29
31
|
when "in"
|
30
32
|
operator = "in (:#{filter_symbol})"
|
31
|
-
criterion
|
33
|
+
# if criterion are anything but numbers, downcase the filter_attribute
|
34
|
+
if criterion.scan(/[^\d|,|\s]/).any?
|
35
|
+
modified_filter_attribute = "lower(#{filter_attribute})"
|
36
|
+
end
|
37
|
+
criterion = criterion.downcase.split(",")
|
32
38
|
filter_symbol_already_embedded = true
|
33
39
|
when "notin"
|
34
40
|
operator = "not in (:#{filter_symbol})"
|
35
|
-
criterion
|
41
|
+
# if criterion are anything but numbers, downcase the filter_attribute
|
42
|
+
if criterion.scan(/[^\d|,|\s]/).any?
|
43
|
+
modified_filter_attribute = "lower(#{filter_attribute})"
|
44
|
+
end
|
45
|
+
criterion = criterion.downcase.split(",")
|
36
46
|
filter_symbol_already_embedded = true
|
37
47
|
when "null"
|
38
48
|
operator = criterion.to_s == "true" ? "is null" : "is not null"
|
@@ -40,7 +50,8 @@ module PatternQueryHelper
|
|
40
50
|
else
|
41
51
|
raise ArgumentError.new("Invalid operator code '#{operator_code}' on '#{filter_attribute}' filter")
|
42
52
|
end
|
43
|
-
|
53
|
+
filter_column = modified_filter_attribute || filter_attribute
|
54
|
+
filter_string = "#{filter_string} and #{filter_column} #{operator}"
|
44
55
|
filter_string << " :#{filter_symbol}" unless filter_symbol_already_embedded or filter_symbol.blank?
|
45
56
|
filter_params["#{filter_symbol}"] = criterion unless filter_symbol.blank?
|
46
57
|
filter_array << {
|