forest_admin_agent 1.12.5 → 1.12.6

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: 269748d517e3b35451f5b029a355b0c4ba4b3edb88d573c154a68b7afbd489a7
4
- data.tar.gz: '079f48afc932a914ce14b9c113b439ba94db05a7af00f411931aa04af3b87f2f'
3
+ metadata.gz: 3e3a7d9a9147c1fd3b2f7113515f86c4a63628907e466414284550a6254dff2f
4
+ data.tar.gz: e9c07eaa78c87c79b4322e3fe630f664d482823ac3397a839e7531c614087c26
5
5
  SHA512:
6
- metadata.gz: f13fe2d602b8c2e3bdd09c10e9af23e85dcd39cd3b7fa4efec8977269920d89510ee36844ff7eb5ef76d9a938b4931c0733c39a8369d8ce91bab12f7a3057a57
7
- data.tar.gz: '059d5f1be122d042b6decf7ebe5e353adfc09a9c21bcddf9f49d581ee1030b35a0dc7b69fdef2847215e20e8df65baef93e635d129ff9d0cd19fd4831123ae0b'
6
+ metadata.gz: b0776a9251a03139b63a12e71c8133c33b2745312be0459c2a25b50a4eeed2b0fbcea5fac11aaf620ef63a05d352082a8a4c19c3b03eb63ecf6ad6c2dafec2d5
7
+ data.tar.gz: fcc5c5a105a2c7cbdc2d6f01090127610b8b523e5821d456af686dc6f3bf217e4d0fe1686fcea98948def0771519034e734dd75b19f5ab5486a1ed486d18644f
@@ -159,9 +159,9 @@ module ForestAdminAgent
159
159
  unless attributes[:parent_association_name].nil?
160
160
  relation = attributes[:parent_association_name]
161
161
  parent = @datasource.get_collection(attributes[:parent_collection_name])
162
- parent_id = Utils::Id.unpack_id(parent, attributes[:parent_collection_id])
162
+ parent_primary_key_values = Utils::Id.unpack_id(parent, attributes[:parent_collection_id])
163
163
 
164
- filter = FilterFactory.make_foreign_filter(parent, parent_id, relation, @caller, filter)
164
+ filter = FilterFactory.make_foreign_filter(parent, parent_primary_key_values, relation, @caller, filter)
165
165
  end
166
166
 
167
167
  filter
@@ -19,8 +19,8 @@ module ForestAdminAgent
19
19
  def handle_request(args = {})
20
20
  build(args)
21
21
  @permissions.can?(:delete, @collection)
22
- id = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
23
- delete_records(args, { ids: [id], are_excluded: false })
22
+ primary_key_values = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
23
+ delete_records(args, { ids: [primary_key_values], are_excluded: false })
24
24
 
25
25
  { content: nil, status: 204 }
26
26
  end
@@ -41,11 +41,20 @@ module ForestAdminAgent
41
41
  @collection.schema[:fields].each_value do |field_schema|
42
42
  next unless ['PolymorphicOneToOne', 'PolymorphicOneToMany'].include?(field_schema.type)
43
43
 
44
+ origin_values = selection_ids[:ids].map do |pk_hash|
45
+ if pk_hash.is_a?(Hash)
46
+ pk_hash[field_schema.origin_key_target]
47
+ else
48
+ pk_names = ForestAdminDatasourceToolkit::Utils::Schema.primary_keys(@collection)
49
+ index = pk_names.index(field_schema.origin_key_target)
50
+ pk_hash[index] if index
51
+ end
52
+ end
53
+
44
54
  condition_tree = Nodes::ConditionTreeBranch.new(
45
55
  'And',
46
56
  [
47
- Nodes::ConditionTreeLeaf.new(field_schema.origin_key, Operators::IN,
48
- selection_ids[:ids].map { |value| value['id'] }),
57
+ Nodes::ConditionTreeLeaf.new(field_schema.origin_key, Operators::IN, origin_values),
49
58
  Nodes::ConditionTreeLeaf.new(field_schema.origin_type_field, Operators::EQUAL,
50
59
  @collection.name.gsub('__', '::'))
51
60
  ]
@@ -24,17 +24,18 @@ module ForestAdminAgent
24
24
  build(args)
25
25
  @permissions.can?(:edit, @collection)
26
26
 
27
- parent_id = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
28
- target_relation_id = Utils::Id.unpack_id(@child_collection, args[:params]['data'][0]['id'], with_key: true)
27
+ parent_primary_key_values = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
28
+ target_primary_key_values = Utils::Id.unpack_id(@child_collection, args[:params]['data'][0]['id'],
29
+ with_key: true)
29
30
  relation = Schema.get_to_many_relation(@collection, args[:params]['relation_name'])
30
31
 
31
32
  case relation.type
32
33
  when 'OneToMany'
33
- associate_one_to_many(relation, parent_id, target_relation_id)
34
+ associate_one_to_many(relation, parent_primary_key_values, target_primary_key_values)
34
35
  when 'ManyToMany'
35
- associate_many_to_many(relation, parent_id, target_relation_id)
36
+ associate_many_to_many(relation, parent_primary_key_values, target_primary_key_values)
36
37
  when 'PolymorphicOneToMany'
37
- associate_polymorphic_one_to_many(relation, parent_id, target_relation_id)
38
+ associate_polymorphic_one_to_many(relation, parent_primary_key_values, target_primary_key_values)
38
39
  end
39
40
 
40
41
  { content: nil, status: 204 }
@@ -42,9 +43,9 @@ module ForestAdminAgent
42
43
 
43
44
  private
44
45
 
45
- def associate_one_to_many(relation, parent_id, target_relation_id)
46
+ def associate_one_to_many(relation, parent_primary_key_values, target_primary_key_values)
46
47
  id = Schema.primary_keys(@child_collection)[0]
47
- value = Collection.get_value(@child_collection, @caller, target_relation_id, id)
48
+ value = Collection.get_value(@child_collection, @caller, target_primary_key_values, id)
48
49
  filter = Filter.new(
49
50
  condition_tree: ConditionTree::ConditionTreeFactory.intersect(
50
51
  [
@@ -53,14 +54,14 @@ module ForestAdminAgent
53
54
  ]
54
55
  )
55
56
  )
56
- value = Collection.get_value(@collection, @caller, parent_id, relation.origin_key_target)
57
+ value = Collection.get_value(@collection, @caller, parent_primary_key_values, relation.origin_key_target)
57
58
 
58
59
  @child_collection.update(@caller, filter, { relation.origin_key => value })
59
60
  end
60
61
 
61
- def associate_polymorphic_one_to_many(relation, parent_id, target_relation_id)
62
+ def associate_polymorphic_one_to_many(relation, parent_primary_key_values, target_primary_key_values)
62
63
  id = Schema.primary_keys(@child_collection)[0]
63
- value = Collection.get_value(@child_collection, @caller, target_relation_id, id)
64
+ value = Collection.get_value(@child_collection, @caller, target_primary_key_values, id)
64
65
  filter = Filter.new(
65
66
  condition_tree: ConditionTree::ConditionTreeFactory.intersect(
66
67
  [
@@ -70,7 +71,7 @@ module ForestAdminAgent
70
71
  )
71
72
  )
72
73
 
73
- value = Collection.get_value(@collection, @caller, parent_id, relation.origin_key_target)
74
+ value = Collection.get_value(@collection, @caller, parent_primary_key_values, relation.origin_key_target)
74
75
 
75
76
  @child_collection.update(
76
77
  @caller,
@@ -79,11 +80,11 @@ module ForestAdminAgent
79
80
  )
80
81
  end
81
82
 
82
- def associate_many_to_many(relation, parent_id, target_relation_id)
83
+ def associate_many_to_many(relation, parent_primary_key_values, target_primary_key_values)
83
84
  id = Schema.primary_keys(@child_collection)[0]
84
- foreign_value = Collection.get_value(@child_collection, @caller, target_relation_id, id)
85
+ foreign_value = Collection.get_value(@child_collection, @caller, target_primary_key_values, id)
85
86
  id = Schema.primary_keys(@collection)[0]
86
- origin_value = Collection.get_value(@collection, @caller, parent_id, id)
87
+ origin_value = Collection.get_value(@collection, @caller, parent_primary_key_values, id)
87
88
  record = { relation.origin_key => origin_value, relation.foreign_key => foreign_value }
88
89
 
89
90
  through_collection = @datasource.get_collection(relation.through_collection)
@@ -25,10 +25,10 @@ module ForestAdminAgent
25
25
 
26
26
  if @child_collection.is_countable?
27
27
  filter = Filter.new(condition_tree: @permissions.get_scope(@collection))
28
- id = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
28
+ primary_key_values = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
29
29
  result = Collection.aggregate_relation(
30
30
  @collection,
31
- id,
31
+ primary_key_values,
32
32
  args[:params]['relation_name'],
33
33
  @caller,
34
34
  filter,
@@ -34,8 +34,8 @@ module ForestAdminAgent
34
34
  )
35
35
  projection = ForestAdminAgent::Utils::QueryStringParser.parse_projection_with_pks(@child_collection, args)
36
36
 
37
- # Get the parent record ID
38
- id = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
37
+ # Get the parent record primary keys
38
+ primary_key_values = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
39
39
  relation_name = args[:params]['relation_name']
40
40
 
41
41
  # Generate timestamp for filename
@@ -48,7 +48,7 @@ module ForestAdminAgent
48
48
  list_records = lambda do |batch_filter|
49
49
  ForestAdminDatasourceToolkit::Utils::Collection.list_relation(
50
50
  @collection,
51
- id,
51
+ primary_key_values,
52
52
  relation_name,
53
53
  @caller,
54
54
  batch_filter,
@@ -22,7 +22,7 @@ module ForestAdminAgent
22
22
  def handle_request(args = {})
23
23
  build(args)
24
24
 
25
- parent_id = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
25
+ parent_primary_key_values = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
26
26
  is_delete_mode = !args.dig(:params, :delete).nil?
27
27
 
28
28
  if is_delete_mode
@@ -35,11 +35,13 @@ module ForestAdminAgent
35
35
  relation = Schema.get_to_many_relation(@collection, args[:params]['relation_name'])
36
36
 
37
37
  if ['OneToMany', 'PolymorphicOneToMany'].include?(relation.type)
38
- dissociate_or_delete_one_to_many(relation, args[:params]['relation_name'], parent_id, is_delete_mode,
39
- filter)
38
+ dissociate_or_delete_one_to_many(
39
+ relation, args[:params]['relation_name'], parent_primary_key_values, is_delete_mode, filter
40
+ )
40
41
  else
41
- dissociate_or_delete_many_to_many(relation, args[:params]['relation_name'], parent_id, is_delete_mode,
42
- filter)
42
+ dissociate_or_delete_many_to_many(
43
+ relation, args[:params]['relation_name'], parent_primary_key_values, is_delete_mode, filter
44
+ )
43
45
  end
44
46
 
45
47
  { content: nil, status: 204 }
@@ -47,8 +49,10 @@ module ForestAdminAgent
47
49
 
48
50
  private
49
51
 
50
- def dissociate_or_delete_one_to_many(relation, relation_name, parent_id, is_delete_mode, filter)
51
- foreign_filter = FilterFactory.make_foreign_filter(@collection, parent_id, relation_name, @caller, filter)
52
+ def dissociate_or_delete_one_to_many(relation, relation_name, parent_primary_key_values, is_delete_mode,
53
+ filter)
54
+ foreign_filter = FilterFactory.make_foreign_filter(@collection, parent_primary_key_values, relation_name,
55
+ @caller, filter)
52
56
 
53
57
  if is_delete_mode
54
58
  @child_collection.delete(@caller, foreign_filter)
@@ -62,13 +66,16 @@ module ForestAdminAgent
62
66
  end
63
67
  end
64
68
 
65
- def dissociate_or_delete_many_to_many(relation, relation_name, parent_id, is_delete_mode, filter)
69
+ def dissociate_or_delete_many_to_many(relation, relation_name, parent_primary_key_values, is_delete_mode,
70
+ filter)
66
71
  through_collection = @datasource.get_collection(relation.through_collection)
67
72
 
68
73
  if is_delete_mode
69
74
  # Generate filters _BEFORE_ deleting stuff, otherwise things break.
70
- foreign_filter = FilterFactory.make_foreign_filter(@collection, parent_id, relation_name, @caller, filter)
71
- through_filter = FilterFactory.make_through_filter(@collection, parent_id, relation_name, @caller, filter)
75
+ foreign_filter = FilterFactory.make_foreign_filter(@collection, parent_primary_key_values, relation_name,
76
+ @caller, filter)
77
+ through_filter = FilterFactory.make_through_filter(@collection, parent_primary_key_values, relation_name,
78
+ @caller, filter)
72
79
 
73
80
  # Delete records from through collection
74
81
  through_collection.delete(@caller, through_filter)
@@ -78,7 +85,8 @@ module ForestAdminAgent
78
85
  # - the underlying database/api is not cascading deletes
79
86
  @child_collection.delete(@caller, foreign_filter)
80
87
  else
81
- through_filter = FilterFactory.make_through_filter(@collection, parent_id, relation_name, @caller, filter)
88
+ through_filter = FilterFactory.make_through_filter(@collection, parent_primary_key_values, relation_name,
89
+ @caller, filter)
82
90
  through_collection.delete(@caller, through_filter)
83
91
  end
84
92
  end
@@ -35,10 +35,10 @@ module ForestAdminAgent
35
35
  sort: ForestAdminAgent::Utils::QueryStringParser.parse_sort(@child_collection, args)
36
36
  )
37
37
  projection = ForestAdminAgent::Utils::QueryStringParser.parse_projection_with_pks(@child_collection, args)
38
- id = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
38
+ primary_key_values = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
39
39
  records = Collection.list_relation(
40
40
  @collection,
41
- id,
41
+ primary_key_values,
42
42
  args[:params]['relation_name'],
43
43
  @caller,
44
44
  filter,
@@ -25,21 +25,21 @@ module ForestAdminAgent
25
25
  @permissions.can?(:edit, @collection)
26
26
 
27
27
  relation = @collection.schema[:fields][args[:params]['relation_name']]
28
- parent_id = Utils::Id.unpack_id(@collection, args[:params]['id'])
28
+ parent_primary_key_values = Utils::Id.unpack_id(@collection, args[:params]['id'])
29
29
 
30
- linked_id = if (id = args.dig(:params, 'data', 'id'))
31
- Utils::Id.unpack_id(@child_collection, id)
32
- end
30
+ linked_primary_key_values = if (id = args.dig(:params, 'data', 'id'))
31
+ Utils::Id.unpack_id(@child_collection, id)
32
+ end
33
33
 
34
34
  case relation.type
35
35
  when 'ManyToOne'
36
- update_many_to_one(relation, parent_id, linked_id)
36
+ update_many_to_one(relation, parent_primary_key_values, linked_primary_key_values)
37
37
  when 'PolymorphicManyToOne'
38
- update_polymorphic_many_to_one(relation, parent_id, linked_id)
38
+ update_polymorphic_many_to_one(relation, parent_primary_key_values, linked_primary_key_values)
39
39
  when 'OneToOne'
40
- update_one_to_one(relation, parent_id, linked_id)
40
+ update_one_to_one(relation, parent_primary_key_values, linked_primary_key_values)
41
41
  when 'PolymorphicOneToOne'
42
- update_polymorphic_one_to_one(relation, parent_id, linked_id)
42
+ update_polymorphic_one_to_one(relation, parent_primary_key_values, linked_primary_key_values)
43
43
  end
44
44
 
45
45
  { content: nil, status: 204 }
@@ -47,26 +47,27 @@ module ForestAdminAgent
47
47
 
48
48
  private
49
49
 
50
- def update_many_to_one(relation, parent_id, linked_id)
51
- foreign_value = if linked_id
52
- Collection.get_value(@child_collection, @caller, linked_id, relation.foreign_key_target)
50
+ def update_many_to_one(relation, parent_primary_key_values, linked_primary_key_values)
51
+ foreign_value = if linked_primary_key_values
52
+ Collection.get_value(@child_collection, @caller, linked_primary_key_values,
53
+ relation.foreign_key_target)
53
54
  end
54
- fk_owner = ConditionTree::ConditionTreeFactory.match_ids(@collection, [parent_id])
55
+ fk_owner = ConditionTree::ConditionTreeFactory.match_ids(@collection, [parent_primary_key_values])
55
56
  @collection.update(@caller, Filter.new(condition_tree: fk_owner), { relation.foreign_key => foreign_value })
56
57
  end
57
58
 
58
- def update_polymorphic_many_to_one(relation, parent_id, linked_id)
59
- foreign_value = if linked_id
59
+ def update_polymorphic_many_to_one(relation, parent_primary_key_values, linked_primary_key_values)
60
+ foreign_value = if linked_primary_key_values
60
61
  Collection.get_value(
61
62
  @child_collection,
62
63
  @caller,
63
- linked_id,
64
+ linked_primary_key_values,
64
65
  relation.foreign_key_targets[@child_collection.name]
65
66
  )
66
67
  end
67
68
 
68
69
  polymorphic_type = @child_collection.name.gsub('__', '::')
69
- fk_owner = ConditionTree::ConditionTreeFactory.match_ids(@collection, [parent_id])
70
+ fk_owner = ConditionTree::ConditionTreeFactory.match_ids(@collection, [parent_primary_key_values])
70
71
  @collection.update(
71
72
  @caller,
72
73
  Filter.new(condition_tree: fk_owner),
@@ -77,22 +78,24 @@ module ForestAdminAgent
77
78
  )
78
79
  end
79
80
 
80
- def update_polymorphic_one_to_one(relation, parent_id, linked_id)
81
- origin_value = Collection.get_value(@collection, @caller, parent_id, relation.origin_key_target)
81
+ def update_polymorphic_one_to_one(relation, parent_primary_key_values, linked_primary_key_values)
82
+ origin_value = Collection.get_value(@collection, @caller, parent_primary_key_values,
83
+ relation.origin_key_target)
82
84
 
83
- break_old_polymorphic_one_to_one_relationship(relation, origin_value, linked_id)
84
- create_new_polymorphic_one_to_one_relationship(relation, origin_value, linked_id)
85
+ break_old_polymorphic_one_to_one_relationship(relation, origin_value, linked_primary_key_values)
86
+ create_new_polymorphic_one_to_one_relationship(relation, origin_value, linked_primary_key_values)
85
87
  end
86
88
 
87
- def update_one_to_one(relation, parent_id, linked_id)
88
- origin_value = Collection.get_value(@collection, @caller, parent_id, relation.origin_key_target)
89
+ def update_one_to_one(relation, parent_primary_key_values, linked_primary_key_values)
90
+ origin_value = Collection.get_value(@collection, @caller, parent_primary_key_values,
91
+ relation.origin_key_target)
89
92
 
90
- break_old_one_to_one_relationship(relation, origin_value, linked_id)
91
- create_new_one_to_one_relationship(relation, origin_value, linked_id)
93
+ break_old_one_to_one_relationship(relation, origin_value, linked_primary_key_values)
94
+ create_new_one_to_one_relationship(relation, origin_value, linked_primary_key_values)
92
95
  end
93
96
 
94
- def break_old_polymorphic_one_to_one_relationship(relation, origin_value, linked_id)
95
- linked_id ||= []
97
+ def break_old_polymorphic_one_to_one_relationship(relation, origin_value, linked_primary_key_values)
98
+ linked_primary_key_values ||= []
96
99
 
97
100
  old_fk_owner_filter = Filter.new(
98
101
  condition_tree: ConditionTree::ConditionTreeFactory.intersect(
@@ -115,7 +118,7 @@ module ForestAdminAgent
115
118
  ),
116
119
  # Don't set the new record's field to null
117
120
  # if it's already initialized with the right value
118
- ConditionTree::ConditionTreeFactory.match_ids(@child_collection, [linked_id]).inverse
121
+ ConditionTree::ConditionTreeFactory.match_ids(@child_collection, [linked_primary_key_values]).inverse
119
122
  ]
120
123
  )
121
124
  )
@@ -133,10 +136,10 @@ module ForestAdminAgent
133
136
  )
134
137
  end
135
138
 
136
- def create_new_polymorphic_one_to_one_relationship(relation, origin_value, linked_id)
137
- return unless linked_id
139
+ def create_new_polymorphic_one_to_one_relationship(relation, origin_value, linked_primary_key_values)
140
+ return unless linked_primary_key_values
138
141
 
139
- new_fk_owner = ConditionTree::ConditionTreeFactory.match_ids(@child_collection, [linked_id])
142
+ new_fk_owner = ConditionTree::ConditionTreeFactory.match_ids(@child_collection, [linked_primary_key_values])
140
143
 
141
144
  @child_collection.update(
142
145
  @caller,
@@ -151,8 +154,8 @@ module ForestAdminAgent
151
154
  )
152
155
  end
153
156
 
154
- def break_old_one_to_one_relationship(relation, origin_value, linked_id)
155
- linked_id ||= []
157
+ def break_old_one_to_one_relationship(relation, origin_value, linked_primary_key_values)
158
+ linked_primary_key_values ||= []
156
159
  old_fk_owner_filter = Filter.new(
157
160
  condition_tree: ConditionTree::ConditionTreeFactory.intersect(
158
161
  [
@@ -164,7 +167,7 @@ module ForestAdminAgent
164
167
  ),
165
168
  # Don't set the new record's field to null
166
169
  # if it's already initialized with the right value
167
- ConditionTree::ConditionTreeFactory.match_ids(@child_collection, [linked_id]).inverse
170
+ ConditionTree::ConditionTreeFactory.match_ids(@child_collection, [linked_primary_key_values]).inverse
168
171
  ]
169
172
  )
170
173
  )
@@ -178,10 +181,10 @@ module ForestAdminAgent
178
181
  @child_collection.update(@caller, old_fk_owner_filter, { relation.origin_key => nil })
179
182
  end
180
183
 
181
- def create_new_one_to_one_relationship(relation, origin_value, linked_id)
182
- return unless linked_id
184
+ def create_new_one_to_one_relationship(relation, origin_value, linked_primary_key_values)
185
+ return unless linked_primary_key_values
183
186
 
184
- new_fk_owner = ConditionTree::ConditionTreeFactory.match_ids(@child_collection, [linked_id])
187
+ new_fk_owner = ConditionTree::ConditionTreeFactory.match_ids(@child_collection, [linked_primary_key_values])
185
188
 
186
189
  @child_collection.update(
187
190
  @caller,
@@ -17,8 +17,8 @@ module ForestAdminAgent
17
17
  build(args)
18
18
  @permissions.can?(:read, @collection)
19
19
  scope = @permissions.get_scope(@collection)
20
- id = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
21
- condition_tree = ConditionTree::ConditionTreeFactory.match_records(@collection, [id])
20
+ primary_key_values = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
21
+ condition_tree = ConditionTree::ConditionTreeFactory.match_records(@collection, [primary_key_values])
22
22
  filter = ForestAdminDatasourceToolkit::Components::Query::Filter.new(
23
23
  condition_tree: ConditionTree::ConditionTreeFactory.intersect([condition_tree, scope])
24
24
  )
@@ -41,7 +41,7 @@ module ForestAdminAgent
41
41
  schema = @collection.schema[:fields][field]
42
42
  next unless %w[OneToOne PolymorphicOneToOne].include?(schema.type)
43
43
 
44
- id = Utils::Id.unpack_id(@collection, value['data']['id'], with_key: true)
44
+ primary_key_values = Utils::Id.unpack_id(@collection, value['data']['id'], with_key: true)
45
45
  foreign_collection = @datasource.get_collection(schema.foreign_collection)
46
46
  # Load the value that will be used as origin_key
47
47
  origin_value = record[schema.origin_key_target]
@@ -49,7 +49,7 @@ module ForestAdminAgent
49
49
  # update new relation (may update zero or one records).
50
50
  patch = { schema.origin_key => origin_value }
51
51
  patch[schema.origin_type_field] = @collection.name.gsub('__', '::') if schema.type == 'PolymorphicOneToOne'
52
- condition_tree = ConditionTree::ConditionTreeFactory.match_records(foreign_collection, [id])
52
+ condition_tree = ConditionTree::ConditionTreeFactory.match_records(foreign_collection, [primary_key_values])
53
53
  filter = Filter.new(condition_tree: condition_tree)
54
54
  foreign_collection.update(@caller, filter, patch)
55
55
  end
@@ -18,8 +18,8 @@ module ForestAdminAgent
18
18
  build(args)
19
19
  @permissions.can?(:edit, @collection)
20
20
  scope = @permissions.get_scope(@collection)
21
- id = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
22
- condition_tree = ConditionTree::ConditionTreeFactory.match_records(@collection, [id])
21
+ primary_key_values = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
22
+ condition_tree = ConditionTree::ConditionTreeFactory.match_records(@collection, [primary_key_values])
23
23
  filter = ForestAdminDatasourceToolkit::Components::Query::Filter.new(
24
24
  condition_tree: ConditionTree::ConditionTreeFactory.intersect([condition_tree, scope])
25
25
  )
@@ -25,7 +25,7 @@ module ForestAdminAgent
25
25
  def handle_request(args = {})
26
26
  build(args)
27
27
 
28
- record_id = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
28
+ primary_key_values = Utils::Id.unpack_id(@collection, args[:params]['id'], with_key: true)
29
29
  field_name = args[:params]['field_name']
30
30
  array_index = parse_index(args[:params]['index'])
31
31
 
@@ -34,7 +34,7 @@ module ForestAdminAgent
34
34
  field_schema = @collection.schema[:fields][field_name]
35
35
  validate_array_field!(field_schema, field_name)
36
36
 
37
- record = fetch_record(record_id)
37
+ record = fetch_record(primary_key_values)
38
38
 
39
39
  array = record[field_name]
40
40
  validate_array_value!(array, field_name, array_index)
@@ -45,7 +45,7 @@ module ForestAdminAgent
45
45
  updated_array[array_index] = new_value
46
46
 
47
47
  scope = @permissions.get_scope(@collection)
48
- condition_tree = ConditionTree::ConditionTreeFactory.match_records(@collection, [record_id])
48
+ condition_tree = ConditionTree::ConditionTreeFactory.match_records(@collection, [primary_key_values])
49
49
  filter = ForestAdminDatasourceToolkit::Components::Query::Filter.new(
50
50
  condition_tree: ConditionTree::ConditionTreeFactory.intersect([condition_tree, scope])
51
51
  )
@@ -87,9 +87,9 @@ module ForestAdminAgent
87
87
  raise Http::Exceptions::ValidationError, e.message
88
88
  end
89
89
 
90
- def fetch_record(record_id)
90
+ def fetch_record(primary_key_values)
91
91
  scope = @permissions.get_scope(@collection)
92
- condition_tree = ConditionTree::ConditionTreeFactory.match_records(@collection, [record_id])
92
+ condition_tree = ConditionTree::ConditionTreeFactory.match_records(@collection, [primary_key_values])
93
93
  filter = ForestAdminDatasourceToolkit::Components::Query::Filter.new(
94
94
  condition_tree: ConditionTree::ConditionTreeFactory.intersect([condition_tree, scope])
95
95
  )
@@ -6,7 +6,7 @@ module ForestAdminAgent
6
6
  module Schema
7
7
  class SchemaEmitter
8
8
  LIANA_NAME = "agent-ruby"
9
- LIANA_VERSION = "1.12.5"
9
+ LIANA_VERSION = "1.12.6"
10
10
 
11
11
  def self.generate(datasource)
12
12
  datasource.collections
@@ -1,3 +1,3 @@
1
1
  module ForestAdminAgent
2
- VERSION = "1.12.5"
2
+ VERSION = "1.12.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_admin_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.5
4
+ version: 1.12.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthieu
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2025-10-24 00:00:00.000000000 Z
12
+ date: 2025-10-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport