forest_liana 9.20.1 → 9.20.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: de38bb4323a6676a9185bee03e2ba490c9b9bc2be0fcb41e213849ef9755c9f2
|
|
4
|
+
data.tar.gz: 54e8bd60a653ecdf126480f2530b15cf52c024d9b69acd3152fd7ffa86f52c0e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c319db67ae5621fd89a52d86e02022b73c4a2872763ec1cc48ef5a43c0f9b47b0ae3fa4927c1d180b60d0af83dfaa6085e788f8e66b91c3213c804a9e5fc56b6
|
|
7
|
+
data.tar.gz: 2d59d2fb65f0b2c05e189e11d25d20dcf9980fe9dc23d4c1f14c96050a7ef67bc7e162731b0fe5f6c0a717557ba9b8b12d98d4481197abc21a69b9d2a1c5b900
|
|
@@ -266,6 +266,9 @@ module ForestLiana
|
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
collection.fields = collection.fields.reject do |field|
|
|
269
|
+
# NOTICE: A primary key column must survive; a type column is never one.
|
|
270
|
+
next false if field[:is_primary_key]
|
|
271
|
+
|
|
269
272
|
field[:field] == association.foreign_key || field[:field] == association.foreign_type
|
|
270
273
|
end
|
|
271
274
|
# NOTICE: Delete the association if the targeted model is excluded.
|
|
@@ -274,7 +277,8 @@ module ForestLiana
|
|
|
274
277
|
x[:field] == association.foreign_key
|
|
275
278
|
end
|
|
276
279
|
|
|
277
|
-
|
|
280
|
+
# NOTICE: A primary key column must survive, even as an excluded association's FK.
|
|
281
|
+
collection.fields.delete(field) if field && !field[:is_primary_key]
|
|
278
282
|
# NOTICE: The foreign key exists, so it's a belongsTo relationship.
|
|
279
283
|
elsif (field = column_association(collection, association)) &&
|
|
280
284
|
[:has_one, :belongs_to].include?(association.macro)
|
data/lib/forest_liana/version.rb
CHANGED
|
@@ -86,6 +86,62 @@ module ForestLiana
|
|
|
86
86
|
ForestLiana.apimap << original if original
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
+
test 'a primary key column that is also the foreign key of an excluded association is kept' do
|
|
90
|
+
excluded_models = ForestLiana.excluded_models
|
|
91
|
+
name = ForestLiana.name_for(BelongsToField)
|
|
92
|
+
original = ForestLiana.apimap.find { |c| c.name.to_s == name }
|
|
93
|
+
ForestLiana.apimap.delete(original) if original
|
|
94
|
+
ForestLiana.excluded_models = [ForestLiana.name_for(HasOneField)]
|
|
95
|
+
BelongsToField.define_singleton_method(:primary_key) { 'has_one_field_id' }
|
|
96
|
+
|
|
97
|
+
schema = SchemaAdapter.new(BelongsToField).perform
|
|
98
|
+
field = schema.fields.find { |f| f[:field] == 'has_one_field_id' }
|
|
99
|
+
|
|
100
|
+
refute_nil field, 'the primary key column must not be deleted'
|
|
101
|
+
assert_equal true, field[:is_primary_key]
|
|
102
|
+
ensure
|
|
103
|
+
BelongsToField.singleton_class.send(:remove_method, :primary_key)
|
|
104
|
+
ForestLiana.excluded_models = excluded_models
|
|
105
|
+
rebuilt = ForestLiana.apimap.find { |c| c.name.to_s == name }
|
|
106
|
+
ForestLiana.apimap.delete(rebuilt) if rebuilt
|
|
107
|
+
ForestLiana.apimap << original if original
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
test 'an ordinary foreign key of an excluded association is still deleted' do
|
|
111
|
+
excluded_models = ForestLiana.excluded_models
|
|
112
|
+
name = ForestLiana.name_for(BelongsToField)
|
|
113
|
+
original = ForestLiana.apimap.find { |c| c.name.to_s == name }
|
|
114
|
+
ForestLiana.apimap.delete(original) if original
|
|
115
|
+
ForestLiana.excluded_models = [ForestLiana.name_for(HasOneField)]
|
|
116
|
+
|
|
117
|
+
schema = SchemaAdapter.new(BelongsToField).perform
|
|
118
|
+
|
|
119
|
+
assert_nil schema.fields.find { |f| f[:field] == 'has_one_field_id' }
|
|
120
|
+
ensure
|
|
121
|
+
ForestLiana.excluded_models = excluded_models
|
|
122
|
+
rebuilt = ForestLiana.apimap.find { |c| c.name.to_s == name }
|
|
123
|
+
ForestLiana.apimap.delete(rebuilt) if rebuilt
|
|
124
|
+
ForestLiana.apimap << original if original
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
test 'a primary key column that is also a polymorphic foreign key is kept' do
|
|
128
|
+
name = ForestLiana.name_for(PolymorphicField)
|
|
129
|
+
original = ForestLiana.apimap.find { |c| c.name.to_s == name }
|
|
130
|
+
ForestLiana.apimap.delete(original) if original
|
|
131
|
+
PolymorphicField.define_singleton_method(:primary_key) { 'has_one_field_id' }
|
|
132
|
+
|
|
133
|
+
schema = SchemaAdapter.new(PolymorphicField).perform
|
|
134
|
+
field = schema.fields.find { |f| f[:field] == 'has_one_field_id' }
|
|
135
|
+
|
|
136
|
+
refute_nil field, 'the primary key column must not be rejected'
|
|
137
|
+
assert_equal true, field[:is_primary_key]
|
|
138
|
+
ensure
|
|
139
|
+
PolymorphicField.singleton_class.send(:remove_method, :primary_key)
|
|
140
|
+
rebuilt = ForestLiana.apimap.find { |c| c.name.to_s == name }
|
|
141
|
+
ForestLiana.apimap.delete(rebuilt) if rebuilt
|
|
142
|
+
ForestLiana.apimap << original if original
|
|
143
|
+
end
|
|
144
|
+
|
|
89
145
|
test 'belongsTo relationship' do
|
|
90
146
|
schema = SchemaAdapter.new(BelongsToField).perform
|
|
91
147
|
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.20.
|
|
4
|
+
version: 9.20.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-07-
|
|
11
|
+
date: 2026-07-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|