effective_resources 2.7.11 → 2.7.13
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bb2a084588e63b0a14f3dedd0005ce818d7a4a7b3019b63d814a91eb1327ea6
|
4
|
+
data.tar.gz: 69f961a1fd267683a614d20c3c1eb2a2b8e6df1d33870bfbe69e8dd4bf5d536b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91fd5726c377ca31a3f93138ea49bf6f84a72224ef01b26dcbf0debf88295e7847769a7cc3e38be54403cba076cb0c8c55154f68305e1e228ea535d475de51e5
|
7
|
+
data.tar.gz: cefcb433e0bbed95da84d1444e0853bffc8171113a4a9439cd4bbb2e843d2ec91e1175604dce95d2962e4f3af7505991fa0be3fa0c45e98b31c0f06e3e787bdb
|
@@ -341,7 +341,7 @@ module Effective
|
|
341
341
|
|
342
342
|
case operation
|
343
343
|
when :eq then relation.where("#{sql_column} = ?", term)
|
344
|
-
when :matches then relation
|
344
|
+
when :matches then search_columns_by_ilike_term(relation, term, columns: name)
|
345
345
|
when :not_eq then relation.where(attribute.not_eq(term))
|
346
346
|
when :does_not_match then relation.where(attribute.does_not_match("%#{term}%"))
|
347
347
|
when :starts_with then relation.where(attribute.matches("#{term}%"))
|
@@ -383,12 +383,37 @@ module Effective
|
|
383
383
|
end
|
384
384
|
|
385
385
|
return relation.none() if columns.blank?
|
386
|
+
search_columns_by_ilike_term(relation, value, columns: columns, fuzzy: fuzzy)
|
387
|
+
end
|
388
|
+
|
389
|
+
private
|
386
390
|
|
387
|
-
|
391
|
+
def search_columns_by_ilike_term(collection, value, columns:, fuzzy: nil)
|
392
|
+
return collection if value.blank?
|
388
393
|
|
389
|
-
|
390
|
-
|
391
|
-
|
394
|
+
raise('unsupported OR and AND syntax') if value.include?(' OR ') && value.include?(' AND ')
|
395
|
+
raise('expected columns') unless columns.present?
|
396
|
+
|
397
|
+
terms = []
|
398
|
+
join = ''
|
399
|
+
|
400
|
+
if value.include?(' OR ')
|
401
|
+
terms = value.split(' OR ')
|
402
|
+
join = ' OR '
|
403
|
+
elsif value.include?(' AND ')
|
404
|
+
terms = value.split(' AND ')
|
405
|
+
join = ' AND '
|
406
|
+
else
|
407
|
+
terms = value.split(' ')
|
408
|
+
join = ' OR '
|
409
|
+
end
|
410
|
+
|
411
|
+
terms = (terms - [nil, '', ' ']).map(&:strip)
|
412
|
+
columns = Array(columns)
|
413
|
+
fuzzy = true if fuzzy.nil?
|
414
|
+
|
415
|
+
# Do the search
|
416
|
+
searched = collection
|
392
417
|
|
393
418
|
terms.each do |term|
|
394
419
|
conditions = (
|
@@ -397,16 +422,14 @@ module Effective
|
|
397
422
|
else
|
398
423
|
columns.map { |name| "#{sql_column(name)} = :term" }
|
399
424
|
end
|
400
|
-
).join(
|
425
|
+
).join(join)
|
401
426
|
|
402
|
-
searched =
|
427
|
+
searched = collection.where(conditions, fuzzy: "%#{term}%", term: term)
|
403
428
|
end
|
404
429
|
|
405
430
|
searched
|
406
431
|
end
|
407
432
|
|
408
|
-
private
|
409
|
-
|
410
433
|
def order_by_associated_conditions(association, sort: nil, direction: :asc, limit: nil)
|
411
434
|
resource = Effective::Resource.new(association)
|
412
435
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.7.
|
4
|
+
version: 2.7.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|