forest_liana 9.14.2 → 9.14.3

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: a594bcf7830da0f415fbfadfa90d985e46814d07cda6892f317f1834db731ce3
4
- data.tar.gz: a565c34a7ef4c7b6e637818963a76b11d772cd716b3eed1db7ffe6b4e8711d2f
3
+ metadata.gz: 82aa2dffa179fa0be6398321388077e3ad04f66583969c4fbb68112983dcd5d6
4
+ data.tar.gz: 9e84f6554455e681cf00ca15cee8bb337c4e9ae22289e11959caa889297a0ee1
5
5
  SHA512:
6
- metadata.gz: c12bd80a362e62935a333d6c9b3df3e8bee0618cb29ef3f0a3677d50b4a33b79a66a09e42b38b3ca2a72cb15c2fdef5542d08a4b190f03ce270ed35ce0d951e4
7
- data.tar.gz: f0a9ea3a170fff1bab99b583d7c5cc491740ffec9b8f48f6de8eee29bc497c77a7d28db34f49b53e08ee49957a3601c4b37be074a4f2a9a7ee1e427fca5df5a8
6
+ metadata.gz: 0cd4367dcab7b965bccf0b49e289509ce0b97b9763491b67273444c06db7a226d4c1fc019da63167567de45afcb752fb76751b4512d0c5ff0754f217679bac0d
7
+ data.tar.gz: 67eb9531fc902db2a9db22cffb6b53ba2f5ff9635f67ef5668db5b107102fb2ddac46b901fa56a7ac245c0fff3215c064b66cede4c37ea819985ce78539346dd
@@ -62,9 +62,8 @@ module ForestLiana
62
62
  end
63
63
 
64
64
  def field_names_requested
65
- return nil unless @params[:fields] && @params[:fields][@collection_name]
66
- @params[:fields][@collection_name].split(',')
67
- .map { |name| name.to_sym }
65
+ fields = @params.dig(:fields, @collection_name)
66
+ Array(fields&.split(',')).map(&:to_sym)
68
67
  end
69
68
 
70
69
  def model_association
@@ -32,7 +32,7 @@ module ForestLiana
32
32
  def perform
33
33
  polymorphic_association, preload_loads = analyze_associations(@resource)
34
34
  includes = @includes.uniq - polymorphic_association - preload_loads - @optional_includes
35
- has_smart_fields = @params[:fields][@collection_name].split(',').any? do |field|
35
+ has_smart_fields = Array(@params.dig(:fields, @collection_name)&.split(',')).any? do |field|
36
36
  ForestLiana::SchemaHelper.is_smart_field?(@resource, field)
37
37
  end
38
38
 
@@ -143,10 +143,8 @@ module ForestLiana
143
143
  includes = associations_has_one.map do |association|
144
144
  association_name = association.name.to_s
145
145
 
146
- if @params[:fields].key?(association_name) &&
147
- @params[:fields][association_name].split(',').size == 1 &&
148
- @params[:fields][association_name].split(',').include?(association.klass.primary_key)
149
-
146
+ fields = @params[:fields]&.[](association_name)&.split(',')
147
+ if fields&.size == 1 && fields.include?(association.klass.primary_key)
150
148
  @field_names_requested << association.foreign_key
151
149
  @optional_includes << association.name
152
150
  end
@@ -191,7 +189,7 @@ module ForestLiana
191
189
  end
192
190
 
193
191
  def field_names_requested
194
- return nil unless @params[:fields] && @params[:fields][@collection_name]
192
+ return [] unless @params.dig(:fields, @collection_name)
195
193
 
196
194
  associations_for_query = extract_associations_from_filter
197
195
  associations_for_query << @params[:sort].split('.').first.to_sym if @params[:sort]&.include?('.')
@@ -332,11 +330,12 @@ module ForestLiana
332
330
  select << "#{@resource.table_name}.#{association.foreign_key}"
333
331
  end
334
332
 
335
- if @params[:fields].key?(path)
333
+ fields = @params[:fields]&.[](path)&.split(',')
334
+ if fields
336
335
  association = get_one_association(path)
337
336
  table_name = association.table_name
338
337
 
339
- @params[:fields][path].split(',').each do |association_path|
338
+ fields.each do |association_path|
340
339
  if ForestLiana::SchemaHelper.is_smart_field?(association.klass, association_path)
341
340
  association.klass.attribute_names.each { |attribute| select << "#{table_name}.#{attribute}" }
342
341
  else
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "9.14.2"
2
+ VERSION = "9.14.3"
3
3
  end
@@ -572,6 +572,26 @@ module ForestLiana
572
572
  expect(records.second.name).to eq 'Treasure'
573
573
  end
574
574
  end
575
+
576
+ describe '#perform' do
577
+ let(:resource) { User }
578
+ let(:fields) { nil }
579
+ let(:sort) { nil }
580
+ let(:filters) { nil }
581
+
582
+ it 'does not raise an error when params[:fields] is nil' do
583
+ expect {
584
+ getter.perform
585
+ }.not_to raise_error
586
+
587
+ records = getter.records
588
+ count = getter.count
589
+
590
+ expect(records).to all(be_a(User))
591
+ expect(count).to eq User.count
592
+ end
593
+ end
594
+
575
595
  end
576
596
  end
577
597
  end
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.14.2
4
+ version: 9.14.3
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-06-10 00:00:00.000000000 Z
11
+ date: 2025-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails