forest_liana 9.18.0 → 9.18.2
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/record_findable.rb +8 -3
- data/app/services/forest_liana/schema_adapter.rb +2 -1
- data/lib/forest_liana/version.rb +1 -1
- data/spec/services/forest_liana/composite_primary_keys_spec.rb +6 -6
- 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: 38c7944d7c156c137b196297c69f904cc8e2506003dcf490cebe6f533f0f51e9
|
|
4
|
+
data.tar.gz: 7738c3daeaf5d9278920974e9d2c3c3f83d1a237b3323bc8f00d289335e113ee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 420b641ccd725591b6413fe4be8e680e77bf97582ddeb75e5f4dee0a7c534fb1564017f5b9df19adc3d0829a04b56ce46147b288e22172cd8f95d72f828271a6
|
|
7
|
+
data.tar.gz: 8b339928ecf3bd9c6f81957b78962936a02510d831510233fb159af39f4fc09228ea0b83f2745557548551171fe7ad101314809e96d72659e984811cb5b04f44
|
|
@@ -14,13 +14,18 @@ module ForestLiana
|
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
# Composite ids reach us in two shapes, both ordered like the model's primary_key:
|
|
18
|
+
# - JSON array "[v1,v2]" -> from the Forest frontend
|
|
19
|
+
# - pipe-joined "v1|v2" -> from the agent-client (workflow executor, Forest convention)
|
|
20
|
+
# Either way the values stay in primary_key order, so find_record can zip them directly.
|
|
17
21
|
def parse_composite_id(id)
|
|
18
22
|
return id if id.is_a?(Array)
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
str = id.to_s
|
|
25
|
+
if str.start_with?('[') && str.end_with?(']')
|
|
26
|
+
JSON.parse(str)
|
|
22
27
|
else
|
|
23
|
-
|
|
28
|
+
str.split('|')
|
|
24
29
|
end
|
|
25
30
|
end
|
|
26
31
|
end
|
|
@@ -279,7 +279,8 @@ module ForestLiana
|
|
|
279
279
|
field[:field] = association.name
|
|
280
280
|
field[:inverse_of] = inverse_of(association)
|
|
281
281
|
field[:relationship] = get_relationship_type(association)
|
|
282
|
-
|
|
282
|
+
# NOTICE: Preserve is_primary_key from the underlying column; a
|
|
283
|
+
# composite PK made of FKs would otherwise lose its flag.
|
|
283
284
|
|
|
284
285
|
ForestLiana::SchemaUtils.disable_filter_and_sort_if_cross_db!(
|
|
285
286
|
field,
|
data/lib/forest_liana/version.rb
CHANGED
|
@@ -30,14 +30,14 @@ module ForestLiana
|
|
|
30
30
|
expect(helper.parse_composite_id('["a","b"]')).to eq(['a', 'b'])
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
it '
|
|
34
|
-
expect(helper.parse_composite_id(
|
|
33
|
+
it 'parses composite ID in pipe-joined format (agent-client / workflow executor)' do
|
|
34
|
+
expect(helper.parse_composite_id('1|2')).to eq(['1', '2'])
|
|
35
|
+
expect(helper.parse_composite_id('10|20')).to eq(['10', '20'])
|
|
36
|
+
expect(helper.parse_composite_id('a|b')).to eq(['a', 'b'])
|
|
35
37
|
end
|
|
36
38
|
|
|
37
|
-
it '
|
|
38
|
-
expect
|
|
39
|
-
helper.parse_composite_id('invalid')
|
|
40
|
-
}.to raise_error(ForestLiana::Errors::HTTP422Error)
|
|
39
|
+
it 'returns array as-is when already an array' do
|
|
40
|
+
expect(helper.parse_composite_id([1, 2])).to eq([1, 2])
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
@@ -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.18.
|
|
4
|
+
version: 9.18.2
|
|
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-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|