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 +4 -4
- data/README.md +20 -0
- data/lib/manageiq/api/common/filter.rb +22 -1
- data/lib/manageiq/api/common/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f53d5e98416af5bcf21e208dd323bf3995fa35cd8b3acb1ecabe6ceb19d44de8
|
4
|
+
data.tar.gz: 0270d9ce153351bdc7d904cd40d226c259ef0ea55ae908bfdfb811c028c59445
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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-
|
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
|