forest_liana 9.10.6 → 9.11.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5cc0a2d3217931e33ca56c2cd0d755515fd84a8ffa132fad2ff8b1bbe6ca8da7
4
- data.tar.gz: e686b67814767f35221acced7c4c8857c4ee4a21e9de94d567fddd042a47d0bc
3
+ metadata.gz: 850c5fe6679c01ceeebc7cf3bd4035a1d69845c434be482d1aec4e1a1e7cb509
4
+ data.tar.gz: d019665e403093766fa60323ed45df69c75e9ba6fb297fcdb4ce7099fee57ceb
5
5
  SHA512:
6
- metadata.gz: 549b9e8b9f579bed560d53f1889df2d00c109fce4047e9f7c783017b0d4ab044273a768fa78afa1e9fc3a876a75c686c83353b1e58dc1652d11746c7d6b59b4b
7
- data.tar.gz: 243e87bc5ebfd56a87bb1953d530a8a21a37a7c12ad4fbef8a38d1433778522559714a8e7a0fb3460ea22a38d29d7586a798e07626a436cef08146ca07cdf11a
6
+ metadata.gz: 5d3190446adab7cebf81af3881bfd959f040b3e106250d3cd562b74cffb002528bb0fe0e0e0b986fcf631e8b3bdaf01937f607f1c86fbb1f5b32b8c3d998f807
7
+ data.tar.gz: 6a751f7b7e2ec02c3b09447d593bc390a05a1fb7ffe0c08cf3ab28fbfeae3dac5ea67039275e96d79f63ea1748b39b0133a98df36859b8ddd3f8d64651df2872
@@ -96,7 +96,8 @@ module ForestLiana
96
96
  value = current_resource.defined_enums[association_field][value]
97
97
  end
98
98
 
99
- parsed_field = parse_field_name(field_name)
99
+ case_insensitive = operator == 'i_contains'
100
+ parsed_field = parse_field_name(field_name, case_insensitive)
100
101
  parsed_operator = parse_operator(operator)
101
102
  parsed_value = parse_value(operator, value)
102
103
  field_and_operator = "#{parsed_field} #{parsed_operator}"
@@ -120,7 +121,7 @@ module ForestLiana
120
121
  '>'
121
122
  when 'less_than', 'before'
122
123
  '<'
123
- when 'contains', 'starts_with', 'ends_with'
124
+ when 'contains', 'starts_with', 'ends_with', 'i_contains'
124
125
  'LIKE'
125
126
  when 'not_contains'
126
127
  'NOT LIKE'
@@ -145,6 +146,8 @@ module ForestLiana
145
146
  value
146
147
  when 'contains', 'not_contains'
147
148
  "%#{value}%"
149
+ when 'i_contains'
150
+ "%#{value.downcase}%"
148
151
  when 'starts_with'
149
152
  "#{value}%"
150
153
  when 'ends_with'
@@ -161,7 +164,7 @@ module ForestLiana
161
164
  end
162
165
  end
163
166
 
164
- def parse_field_name(field)
167
+ def parse_field_name(field, insensitive = false)
165
168
  if is_belongs_to(field)
166
169
  current_resource = @resource.reflect_on_association(field.split(':').first.to_sym)&.klass
167
170
  raise ForestLiana::Errors::HTTP422Error.new("Field '#{field}' not found") unless current_resource
@@ -181,7 +184,7 @@ module ForestLiana
181
184
  raise ForestLiana::Errors::HTTP422Error.new("Field '#{field}' not found")
182
185
  end
183
186
 
184
- "#{quoted_table_name}.#{quoted_field_name}"
187
+ insensitive ? "LOWER(#{quoted_table_name}.#{quoted_field_name})" : "#{quoted_table_name}.#{quoted_field_name}"
185
188
  end
186
189
 
187
190
  def is_belongs_to(field)
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "9.10.6"
2
+ VERSION = "9.11.0"
3
3
  end
@@ -281,6 +281,12 @@ module ForestLiana
281
281
  it { expect(result).to eq "\"trees\".\"name\" LIKE '%3'" }
282
282
  end
283
283
 
284
+ context 'when the condition uses the i_contains operator' do
285
+ let(:condition) { { 'field' => 'name', 'operator' => 'i_contains', 'value' => 'Tree' } }
286
+
287
+ it { expect(result).to eq "LOWER(\"trees\".\"name\") LIKE '%tree%'" }
288
+ end
289
+
284
290
  context 'when the condition uses the blank operator' do
285
291
  let(:condition) { { 'field' => 'name', 'operator' => 'blank' } }
286
292
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_liana
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.10.6
4
+ version: 9.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Munda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-11 00:00:00.000000000 Z
11
+ date: 2025-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails