rad_core_rails 0.8.0 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rad_core_rails/query_generator.rb +39 -14
- data/lib/rad_core_rails/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: 94385bc06e9963131ae34f6bb60e292d1d17843e33ec172d6b77208d62a8fd42
|
4
|
+
data.tar.gz: e7633994fc346ba6a735201173be955121b5d53b9147eefb433ae99864e5fc6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dde266785258fbd7c1f94c9c40769498693f06ba0a4bff7a6787d5e9b6c8cf7ac4986277ea6bd22ecff9079708584473fbf47078a3215c3eb6e469a3ed88cfa
|
7
|
+
data.tar.gz: adb7160fc0842d87a3653583134678e407c4364f72d400045a19621a8eb2bd584be5079f2e43fd176846b5dd3e248ccf9ba90ff36be1dec9adc28ac9f2440cfb
|
@@ -179,14 +179,35 @@ module RadCoreRails
|
|
179
179
|
end
|
180
180
|
|
181
181
|
def generate_model_clause(column_name, filter, optional_exclusion_clause = nil)
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
182
|
+
if optional_exclusion_clause.present? && filter[:option] == '!='
|
183
|
+
str = optional_exclusion_clause
|
184
|
+
args = [filter[:values]]
|
185
|
+
elsif filter[:option] == '!!'
|
186
|
+
str = "(#{column_name} IS NULL)"
|
187
|
+
args = []
|
188
|
+
else
|
189
|
+
# probably should fix this.
|
190
|
+
# somtimes we arent sending a filter option, so just default it to =
|
191
|
+
str = "(#{column_name} #{filter[:option] || '='} ANY(ARRAY[?]))"
|
192
|
+
args = [filter[:values]]
|
193
|
+
end
|
194
|
+
|
195
|
+
[str, args]
|
196
|
+
end
|
197
|
+
|
198
|
+
def generate_string_clause(column_name, filter, optional_exclusion_clause = nil)
|
199
|
+
if optional_exclusion_clause.present? && filter[:option] == '!='
|
200
|
+
str = optional_exclusion_clause
|
201
|
+
args = [filter[:values]]
|
202
|
+
elsif filter[:option] == '!!'
|
203
|
+
str = "(#{column_name} IS NULL OR #{column_name} = '')"
|
204
|
+
args = []
|
205
|
+
else
|
206
|
+
# probably should fix this.
|
207
|
+
# somtimes we arent sending a filter option, so just default it to =
|
208
|
+
str = "(#{column_name} #{filter[:option] || '='} ANY(ARRAY[?]))"
|
209
|
+
args = [filter[:values]]
|
210
|
+
end
|
190
211
|
|
191
212
|
[str, args]
|
192
213
|
end
|
@@ -206,17 +227,17 @@ module RadCoreRails
|
|
206
227
|
|
207
228
|
sanitized_and_terms = search.split(' ')
|
208
229
|
.reject { |term| term.include?('+') || term.include?('-') }
|
209
|
-
.map { |term| term.downcase.strip
|
230
|
+
.map { |term| term.downcase.strip + ':*' }
|
210
231
|
.reject { |t| t.blank? }
|
211
232
|
|
212
233
|
sanitized_or_terms = search.split(' ')
|
213
234
|
.select { |term| term.include?('+') }
|
214
|
-
.map { |term| term[1, term.length].downcase
|
235
|
+
.map { |term| term[1, term.length].downcase + ':*' }
|
215
236
|
.reject { |t| t.blank? }
|
216
237
|
|
217
238
|
sanitized_excluded_terms = search.split(' ')
|
218
239
|
.select { |term| term.include?('-') }
|
219
|
-
.map { |term| term[1, term.length].downcase.strip
|
240
|
+
.map { |term| term[1, term.length].downcase.strip + ':*' }
|
220
241
|
.reject { |t| t.blank? }
|
221
242
|
|
222
243
|
and_clause = sanitized_and_terms.join(' & ')
|
@@ -255,9 +276,10 @@ module RadCoreRails
|
|
255
276
|
|
256
277
|
def generate_vector_clause(column_name, filter)
|
257
278
|
return ['', []] if filter[:values][0].blank?
|
279
|
+
|
258
280
|
vector_string = sanitize_vector_string(filter[:values][0])
|
259
281
|
|
260
|
-
query = "(#{column_name} @@ to_tsquery('
|
282
|
+
query = "(#{column_name} @@ to_tsquery('simple', ?))"
|
261
283
|
[query, [vector_string]]
|
262
284
|
end
|
263
285
|
|
@@ -270,10 +292,13 @@ module RadCoreRails
|
|
270
292
|
|
271
293
|
def generate_array_clause(column_name, filter)
|
272
294
|
if filter[:option] == '!='
|
273
|
-
str = "(SELECT NOT(#{column_name}::text[] && ARRAY[?]))"
|
295
|
+
str = "(SELECT NOT(#{column_name}::text[] && ARRAY[?]::text[]))"
|
274
296
|
args = [filter[:values]]
|
297
|
+
elsif filter[:option] == '!!'
|
298
|
+
str = "(#{column_name}::text[] = '{}')"
|
299
|
+
args = []
|
275
300
|
else
|
276
|
-
str = "(SELECT (#{column_name}::text[] && ARRAY[?]))"
|
301
|
+
str = "(SELECT (#{column_name}::text[] && ARRAY[?]::text[]))"
|
277
302
|
args = [filter[:values]]
|
278
303
|
end
|
279
304
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rad_core_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleksandr Poltavets, James Marrs
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|