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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82aa2dffa179fa0be6398321388077e3ad04f66583969c4fbb68112983dcd5d6
|
4
|
+
data.tar.gz: 9e84f6554455e681cf00ca15cee8bb337c4e9ae22289e11959caa889297a0ee1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
66
|
-
|
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 =
|
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
|
-
|
147
|
-
|
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
|
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
|
-
|
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
|
-
|
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
|
data/lib/forest_liana/version.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2025-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|