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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9478c942fdda25782ac53d2adc8aeea980719414857098383a5c5b6cfbecf6a
4
- data.tar.gz: d5cf42e0b74a810e5111bb42e78595c7fca64ecd87657b7af6a23baa7765cc53
3
+ metadata.gz: 6c3503df41d4640984dac6772f15d439c23b8fd3904514d58fb98b2af7efbc45
4
+ data.tar.gz: d40370dd2f2e9c2da4b0993a7ac21d08dbc512b76bd2da031ff1e3ce56605507
5
5
  SHA512:
6
- metadata.gz: 59ea5d4b72d30ab2761f1f72fc43546ac20c2f48cb3e5924c95e81522a535a526be3f074226e6fc911b36b7dd1f902c5a897e2fa0c1166748635e30424f3ec74
7
- data.tar.gz: b90f41129c7aea623290ffe882e981327b6604a821fc1536ff3eac67350ac05ece354c1a82605df0886612b4ff6795b4ee7752d3550ca4442ae2b804ad21ae7b
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.5)
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.2)
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.16.6
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 = criterion.split(",")
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 = criterion.split(",")
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
- filter_string = "#{filter_string} and #{filter_attribute} #{operator}"
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 << {
@@ -1,3 +1,3 @@
1
1
  module PatternQueryHelper
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pattern_query_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan McDaniel