manageiq-api-common 1.0.2 → 1.1.0

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: 5519a66dd882a8f565db2c38e909cb3f67b51007f924745aa1f68870277e4d2c
4
- data.tar.gz: 324c43f0e1d2370dfbf5e6c59eb6c52c7fa6a9629666d9c17d2e01d67272e058
3
+ metadata.gz: f53d5e98416af5bcf21e208dd323bf3995fa35cd8b3acb1ecabe6ceb19d44de8
4
+ data.tar.gz: 0270d9ce153351bdc7d904cd40d226c259ef0ea55ae908bfdfb811c028c59445
5
5
  SHA512:
6
- metadata.gz: 8ceb44beafb47407adc89922599b12e9daef1d177e38b54797c1cf20e8af86671ba0f858a305cf7e47a76f44d2526ce9a52ab66ec4786653c3ebbe11a51f232e
7
- data.tar.gz: ad9a55c49bf3b54640927d047ff37d7e75019f37f17e3afab7956a12dab819ae3d3dd98eb0628b00aa7ee2d34545e0dc945382726d47e58c94a0904db49cb235
6
+ metadata.gz: fbbf638e19fdf20d3575fed8db27e20e009d444f35ca86a2e6d03613ab41a8723d19ab59c4c77e9e9f4d978b3a07e5b8ef0aae6afc4b147d256f9041d4933fb7
7
+ data.tar.gz: 486713b3545ef4d3eeb5666c0c74c9669d2dc9cbe9bd81757872d8a4c4ff9b805813d068d11ecd0b6037947346b5fffb750bcca53cd806e47263088b914352fd
data/README.md CHANGED
@@ -29,6 +29,26 @@ Or install it yourself as:
29
29
 
30
30
  #### ManageIQ::Api::Common::Filter
31
31
 
32
+ | Supported Comparators | Comparator |
33
+ | --------------------- | ---------- |
34
+ | Integer | eq |
35
+ | | gt |
36
+ | | gte |
37
+ | | lt |
38
+ | | lte |
39
+ | | nil |
40
+ | | not_nil |
41
+ | String | eq |
42
+ | | contains |
43
+ | | starts_with |
44
+ | | ends_with |
45
+ | | nil |
46
+ | | not_nil |
47
+ | String (case insensitive) | eq_i |
48
+ | | contains_i |
49
+ | | starts_with_i |
50
+ | | ends_with_i |
51
+
32
52
  After implementing filtering in your application, this is the way to filter via parameters on index functions:
33
53
 
34
54
  | Query Parameter | Ruby Client Parameter <br> **GraphQL filter: Parameter** |
@@ -3,7 +3,7 @@ module ManageIQ
3
3
  module Common
4
4
  class Filter
5
5
  INTEGER_COMPARISON_KEYWORDS = ["eq", "gt", "gte", "lt", "lte", "nil", "not_nil"].freeze
6
- STRING_COMPARISON_KEYWORDS = ["contains", "eq", "starts_with", "ends_with", "nil", "not_nil"].freeze
6
+ STRING_COMPARISON_KEYWORDS = ["contains", "contains_i", "eq", "eq_i", "starts_with", "starts_with_i", "ends_with", "ends_with_i", "nil", "not_nil"].freeze
7
7
 
8
8
  attr_reader :apply, :arel_table, :api_doc_definition
9
9
 
@@ -116,21 +116,42 @@ module ManageIQ
116
116
 
117
117
  def comparator_contains(key, value)
118
118
  return value.each { |v| comparator_contains(key, v) } if value.kind_of?(Array)
119
+
119
120
  self.query = query.where(arel_table[key].matches("%#{query.sanitize_sql_like(value)}%", nil, true))
120
121
  end
121
122
 
123
+ def comparator_contains_i(key, value)
124
+ return value.each { |v| comparator_contains_i(key, v) } if value.kind_of?(Array)
125
+
126
+ self.query = query.where(arel_table[key].lower.matches("%#{query.sanitize_sql_like(value.downcase)}%", nil, true))
127
+ end
128
+
122
129
  def comparator_starts_with(key, value)
123
130
  self.query = query.where(arel_table[key].matches("#{query.sanitize_sql_like(value)}%", nil, true))
124
131
  end
125
132
 
133
+ def comparator_starts_with_i(key, value)
134
+ self.query = query.where(arel_table[key].lower.matches("#{query.sanitize_sql_like(value.downcase)}%", nil, true))
135
+ end
136
+
126
137
  def comparator_ends_with(key, value)
127
138
  self.query = query.where(arel_table[key].matches("%#{query.sanitize_sql_like(value)}", nil, true))
128
139
  end
129
140
 
141
+ def comparator_ends_with_i(key, value)
142
+ self.query = query.where(arel_table[key].lower.matches("%#{query.sanitize_sql_like(value.downcase)}", nil, true))
143
+ end
144
+
130
145
  def comparator_eq(key, value)
131
146
  self.query = query.where(key => value)
132
147
  end
133
148
 
149
+ def comparator_eq_i(key, value)
150
+ values = Array(value).map { |v| query.sanitize_sql_like(v.downcase) }
151
+
152
+ self.query = query.where(arel_table[key].lower.matches_any(values))
153
+ end
154
+
134
155
  def comparator_gt(key, value)
135
156
  self.query = query.where(arel_table[key].gt(value))
136
157
  end
@@ -1,7 +1,7 @@
1
1
  module ManageIQ
2
2
  module API
3
3
  module Common
4
- VERSION = "1.0.2".freeze
4
+ VERSION = "1.1.0".freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manageiq-api-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ManageIQ Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-07 00:00:00.000000000 Z
11
+ date: 2019-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: acts_as_tenant