forest_liana 9.18.1 → 9.19.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 +4 -4
- data/app/services/forest_liana/apimap_sorter.rb +1 -0
- data/app/services/forest_liana/schema_adapter.rb +6 -2
- data/lib/forest_liana/schema_file_updater.rb +1 -0
- data/lib/forest_liana/version.rb +1 -1
- data/spec/lib/forest_liana/schema_file_updater_spec.rb +2 -1
- data/spec/services/forest_liana/schema_adapter_spec.rb +2 -1
- data/test/services/forest_liana/schema_adapter_test.rb +17 -0
- 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: 92281c1baf13dfbbdbe418f2a11833ad15a665c1109f1e4ad0a5f395e32ab090
|
|
4
|
+
data.tar.gz: 71946c62175f706e11528dbac2a3e7600f780a7847596be724c74675ef8299a0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f6eced39681d8c424791ed625807cb3ce9e8e741a9ed7f1ca711f225219219d2415cafa222b8df4eaa99185f57c98ca2f8766df724719d36e791af695ad1f2ee
|
|
7
|
+
data.tar.gz: 4df825ec3296694e8fcf7cdc0d7eb86a481667af477ce9b7e500ba69afdc1bb86d343049f2493d896c9a70dc19100f984dcd301e5da80703520cf17ae0121dcc
|
|
@@ -259,7 +259,10 @@ module ForestLiana
|
|
|
259
259
|
relationships: nil,
|
|
260
260
|
widget: nil,
|
|
261
261
|
validations: [],
|
|
262
|
-
polymorphic_referenced_models: get_polymorphic_types(association)
|
|
262
|
+
polymorphic_referenced_models: get_polymorphic_types(association),
|
|
263
|
+
# NOTICE: Expose the discriminator column (e.g. "addressable_type")
|
|
264
|
+
# so consumers can resolve which model a record targets.
|
|
265
|
+
foreign_key_type_field: association.foreign_type
|
|
263
266
|
}
|
|
264
267
|
|
|
265
268
|
collection.fields = collection.fields.reject do |field|
|
|
@@ -279,7 +282,8 @@ module ForestLiana
|
|
|
279
282
|
field[:field] = association.name
|
|
280
283
|
field[:inverse_of] = inverse_of(association)
|
|
281
284
|
field[:relationship] = get_relationship_type(association)
|
|
282
|
-
|
|
285
|
+
# NOTICE: Preserve is_primary_key from the underlying column; a
|
|
286
|
+
# composite PK made of FKs would otherwise lose its flag.
|
|
283
287
|
|
|
284
288
|
ForestLiana::SchemaUtils.disable_filter_and_sort_if_cross_db!(
|
|
285
289
|
field,
|
data/lib/forest_liana/version.rb
CHANGED
|
@@ -32,7 +32,8 @@ module ForestLiana
|
|
|
32
32
|
"relationships" => nil,
|
|
33
33
|
"widget" => nil,
|
|
34
34
|
"validations" => [],
|
|
35
|
-
"polymorphic_referenced_models" => ["User"]
|
|
35
|
+
"polymorphic_referenced_models" => ["User"],
|
|
36
|
+
"foreign_key_type_field" => "addressable_type"
|
|
36
37
|
},
|
|
37
38
|
],
|
|
38
39
|
"actions" => [],
|
|
@@ -69,6 +69,23 @@ module ForestLiana
|
|
|
69
69
|
assert_equal false, schema[:is_primary_key]
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
+
test 'a foreign key composing the primary key keeps is_primary_key: true once turned into an association' do
|
|
73
|
+
name = ForestLiana.name_for(BelongsToField)
|
|
74
|
+
original = ForestLiana.apimap.find { |c| c.name.to_s == name }
|
|
75
|
+
ForestLiana.apimap.delete(original) if original
|
|
76
|
+
BelongsToField.define_singleton_method(:primary_key) { ['id', 'has_one_field_id'] }
|
|
77
|
+
|
|
78
|
+
schema = SchemaAdapter.new(BelongsToField).perform
|
|
79
|
+
field = schema.fields.find { |f| f[:field] == :has_one_field }
|
|
80
|
+
|
|
81
|
+
assert_equal true, field[:is_primary_key]
|
|
82
|
+
ensure
|
|
83
|
+
BelongsToField.singleton_class.send(:remove_method, :primary_key)
|
|
84
|
+
rebuilt = ForestLiana.apimap.find { |c| c.name.to_s == name }
|
|
85
|
+
ForestLiana.apimap.delete(rebuilt) if rebuilt
|
|
86
|
+
ForestLiana.apimap << original if original
|
|
87
|
+
end
|
|
88
|
+
|
|
72
89
|
test 'belongsTo relationship' do
|
|
73
90
|
schema = SchemaAdapter.new(BelongsToField).perform
|
|
74
91
|
fields = schema.fields.select do |field|
|
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.
|
|
4
|
+
version: 9.19.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: 2026-06-
|
|
11
|
+
date: 2026-06-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|