infrahub-server 1.2.12__py3-none-any.whl → 1.3.0__py3-none-any.whl

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.
Files changed (205) hide show
  1. infrahub/actions/constants.py +130 -0
  2. infrahub/actions/gather.py +114 -0
  3. infrahub/actions/models.py +243 -0
  4. infrahub/actions/parsers.py +104 -0
  5. infrahub/actions/schema.py +393 -0
  6. infrahub/actions/tasks.py +119 -0
  7. infrahub/actions/triggers.py +21 -0
  8. infrahub/branch/__init__.py +0 -0
  9. infrahub/branch/tasks.py +29 -0
  10. infrahub/branch/triggers.py +22 -0
  11. infrahub/cli/db.py +3 -4
  12. infrahub/computed_attribute/gather.py +3 -1
  13. infrahub/computed_attribute/tasks.py +23 -29
  14. infrahub/core/account.py +24 -47
  15. infrahub/core/attribute.py +13 -15
  16. infrahub/core/constants/__init__.py +10 -0
  17. infrahub/core/constants/infrahubkind.py +9 -0
  18. infrahub/core/constraint/node/runner.py +3 -1
  19. infrahub/core/convert_object_type/__init__.py +0 -0
  20. infrahub/core/convert_object_type/conversion.py +124 -0
  21. infrahub/core/convert_object_type/schema_mapping.py +56 -0
  22. infrahub/core/diff/coordinator.py +8 -1
  23. infrahub/core/diff/query/all_conflicts.py +1 -5
  24. infrahub/core/diff/query/artifact.py +10 -20
  25. infrahub/core/diff/query/delete_query.py +8 -4
  26. infrahub/core/diff/query/diff_get.py +3 -6
  27. infrahub/core/diff/query/field_specifiers.py +1 -1
  28. infrahub/core/diff/query/field_summary.py +2 -4
  29. infrahub/core/diff/query/merge.py +72 -125
  30. infrahub/core/diff/query/save.py +28 -43
  31. infrahub/core/diff/query/summary_counts_enricher.py +34 -54
  32. infrahub/core/diff/query/time_range_query.py +0 -1
  33. infrahub/core/diff/repository/repository.py +4 -0
  34. infrahub/core/manager.py +14 -11
  35. infrahub/core/migrations/graph/m003_relationship_parent_optional.py +1 -2
  36. infrahub/core/migrations/graph/m012_convert_account_generic.py +1 -1
  37. infrahub/core/migrations/graph/m013_convert_git_password_credential.py +2 -6
  38. infrahub/core/migrations/graph/m015_diff_format_update.py +1 -2
  39. infrahub/core/migrations/graph/m016_diff_delete_bug_fix.py +1 -2
  40. infrahub/core/migrations/graph/m019_restore_rels_to_time.py +11 -22
  41. infrahub/core/migrations/graph/m020_duplicate_edges.py +3 -6
  42. infrahub/core/migrations/graph/m021_missing_hierarchy_merge.py +1 -2
  43. infrahub/core/migrations/graph/m023_deduplicate_cardinality_one_relationships.py +2 -2
  44. infrahub/core/migrations/graph/m024_missing_hierarchy_backfill.py +1 -2
  45. infrahub/core/migrations/graph/m028_delete_diffs.py +1 -2
  46. infrahub/core/migrations/graph/m029_duplicates_cleanup.py +30 -48
  47. infrahub/core/migrations/graph/m030_illegal_edges.py +1 -2
  48. infrahub/core/migrations/query/attribute_add.py +1 -2
  49. infrahub/core/migrations/query/attribute_rename.py +6 -11
  50. infrahub/core/migrations/query/delete_element_in_schema.py +19 -17
  51. infrahub/core/migrations/query/node_duplicate.py +19 -21
  52. infrahub/core/migrations/query/relationship_duplicate.py +19 -18
  53. infrahub/core/migrations/schema/node_attribute_remove.py +4 -8
  54. infrahub/core/migrations/schema/node_remove.py +19 -20
  55. infrahub/core/models.py +29 -2
  56. infrahub/core/node/__init__.py +131 -28
  57. infrahub/core/node/base.py +1 -1
  58. infrahub/core/node/create.py +211 -0
  59. infrahub/core/node/resource_manager/number_pool.py +31 -5
  60. infrahub/core/node/standard.py +6 -1
  61. infrahub/core/path.py +15 -1
  62. infrahub/core/protocols.py +57 -0
  63. infrahub/core/protocols_base.py +3 -0
  64. infrahub/core/query/__init__.py +2 -2
  65. infrahub/core/query/delete.py +3 -3
  66. infrahub/core/query/diff.py +19 -32
  67. infrahub/core/query/ipam.py +10 -20
  68. infrahub/core/query/node.py +29 -47
  69. infrahub/core/query/relationship.py +55 -34
  70. infrahub/core/query/resource_manager.py +1 -2
  71. infrahub/core/query/standard_node.py +19 -5
  72. infrahub/core/query/subquery.py +2 -4
  73. infrahub/core/relationship/constraints/count.py +10 -9
  74. infrahub/core/relationship/constraints/interface.py +2 -1
  75. infrahub/core/relationship/constraints/peer_kind.py +2 -1
  76. infrahub/core/relationship/constraints/peer_parent.py +56 -0
  77. infrahub/core/relationship/constraints/peer_relatives.py +72 -0
  78. infrahub/core/relationship/constraints/profiles_kind.py +1 -1
  79. infrahub/core/relationship/model.py +4 -1
  80. infrahub/core/schema/__init__.py +2 -1
  81. infrahub/core/schema/attribute_parameters.py +160 -0
  82. infrahub/core/schema/attribute_schema.py +130 -7
  83. infrahub/core/schema/basenode_schema.py +27 -3
  84. infrahub/core/schema/definitions/core/__init__.py +29 -1
  85. infrahub/core/schema/definitions/core/group.py +45 -0
  86. infrahub/core/schema/definitions/core/resource_pool.py +9 -0
  87. infrahub/core/schema/definitions/internal.py +43 -5
  88. infrahub/core/schema/generated/attribute_schema.py +16 -3
  89. infrahub/core/schema/generated/relationship_schema.py +11 -1
  90. infrahub/core/schema/manager.py +7 -2
  91. infrahub/core/schema/schema_branch.py +104 -9
  92. infrahub/core/validators/__init__.py +15 -2
  93. infrahub/core/validators/attribute/choices.py +1 -3
  94. infrahub/core/validators/attribute/enum.py +1 -3
  95. infrahub/core/validators/attribute/kind.py +1 -3
  96. infrahub/core/validators/attribute/length.py +13 -7
  97. infrahub/core/validators/attribute/min_max.py +118 -0
  98. infrahub/core/validators/attribute/number_pool.py +106 -0
  99. infrahub/core/validators/attribute/optional.py +1 -4
  100. infrahub/core/validators/attribute/regex.py +5 -6
  101. infrahub/core/validators/attribute/unique.py +1 -3
  102. infrahub/core/validators/determiner.py +18 -2
  103. infrahub/core/validators/enum.py +12 -0
  104. infrahub/core/validators/node/hierarchy.py +3 -6
  105. infrahub/core/validators/query.py +1 -3
  106. infrahub/core/validators/relationship/count.py +6 -12
  107. infrahub/core/validators/relationship/optional.py +2 -4
  108. infrahub/core/validators/relationship/peer.py +177 -12
  109. infrahub/core/validators/tasks.py +1 -1
  110. infrahub/core/validators/uniqueness/query.py +5 -9
  111. infrahub/database/__init__.py +12 -4
  112. infrahub/database/validation.py +1 -2
  113. infrahub/dependencies/builder/constraint/grouped/node_runner.py +4 -0
  114. infrahub/dependencies/builder/constraint/relationship_manager/peer_parent.py +8 -0
  115. infrahub/dependencies/builder/constraint/relationship_manager/peer_relatives.py +8 -0
  116. infrahub/dependencies/builder/constraint/schema/aggregated.py +2 -0
  117. infrahub/dependencies/builder/constraint/schema/relationship_peer.py +8 -0
  118. infrahub/dependencies/builder/diff/deserializer.py +1 -1
  119. infrahub/dependencies/registry.py +4 -0
  120. infrahub/events/group_action.py +1 -0
  121. infrahub/events/models.py +1 -1
  122. infrahub/git/base.py +5 -3
  123. infrahub/git/integrator.py +96 -5
  124. infrahub/git/tasks.py +1 -0
  125. infrahub/graphql/analyzer.py +139 -18
  126. infrahub/graphql/manager.py +4 -0
  127. infrahub/graphql/mutations/action.py +164 -0
  128. infrahub/graphql/mutations/convert_object_type.py +71 -0
  129. infrahub/graphql/mutations/main.py +24 -175
  130. infrahub/graphql/mutations/proposed_change.py +20 -17
  131. infrahub/graphql/mutations/relationship.py +32 -0
  132. infrahub/graphql/mutations/resource_manager.py +63 -7
  133. infrahub/graphql/queries/convert_object_type_mapping.py +34 -0
  134. infrahub/graphql/queries/resource_manager.py +7 -1
  135. infrahub/graphql/resolvers/many_relationship.py +1 -1
  136. infrahub/graphql/resolvers/resolver.py +2 -2
  137. infrahub/graphql/resolvers/single_relationship.py +1 -1
  138. infrahub/graphql/schema.py +6 -0
  139. infrahub/menu/menu.py +34 -2
  140. infrahub/message_bus/messages/__init__.py +0 -10
  141. infrahub/message_bus/operations/__init__.py +0 -8
  142. infrahub/message_bus/operations/refresh/registry.py +3 -6
  143. infrahub/patch/queries/delete_duplicated_edges.py +10 -15
  144. infrahub/pools/models.py +14 -0
  145. infrahub/pools/number.py +5 -3
  146. infrahub/pools/registration.py +22 -0
  147. infrahub/pools/tasks.py +126 -0
  148. infrahub/prefect_server/models.py +1 -19
  149. infrahub/proposed_change/models.py +68 -3
  150. infrahub/proposed_change/tasks.py +911 -34
  151. infrahub/schema/__init__.py +0 -0
  152. infrahub/schema/tasks.py +27 -0
  153. infrahub/schema/triggers.py +23 -0
  154. infrahub/task_manager/models.py +10 -6
  155. infrahub/trigger/catalogue.py +6 -0
  156. infrahub/trigger/models.py +23 -6
  157. infrahub/trigger/setup.py +26 -2
  158. infrahub/trigger/tasks.py +4 -2
  159. infrahub/types.py +6 -0
  160. infrahub/webhook/tasks.py +4 -8
  161. infrahub/workflows/catalogue.py +103 -1
  162. infrahub_sdk/client.py +43 -10
  163. infrahub_sdk/ctl/generator.py +4 -4
  164. infrahub_sdk/ctl/repository.py +1 -1
  165. infrahub_sdk/node/__init__.py +39 -0
  166. infrahub_sdk/node/attribute.py +122 -0
  167. infrahub_sdk/node/constants.py +21 -0
  168. infrahub_sdk/{node.py → node/node.py} +158 -803
  169. infrahub_sdk/node/parsers.py +15 -0
  170. infrahub_sdk/node/property.py +24 -0
  171. infrahub_sdk/node/related_node.py +266 -0
  172. infrahub_sdk/node/relationship.py +302 -0
  173. infrahub_sdk/protocols.py +112 -0
  174. infrahub_sdk/protocols_base.py +34 -2
  175. infrahub_sdk/pytest_plugin/items/python_transform.py +2 -1
  176. infrahub_sdk/query_groups.py +17 -5
  177. infrahub_sdk/schema/main.py +1 -0
  178. infrahub_sdk/schema/repository.py +16 -0
  179. infrahub_sdk/spec/object.py +1 -1
  180. infrahub_sdk/store.py +1 -1
  181. infrahub_sdk/testing/schemas/car_person.py +1 -0
  182. infrahub_sdk/utils.py +7 -20
  183. infrahub_sdk/yaml.py +6 -5
  184. {infrahub_server-1.2.12.dist-info → infrahub_server-1.3.0.dist-info}/METADATA +3 -3
  185. {infrahub_server-1.2.12.dist-info → infrahub_server-1.3.0.dist-info}/RECORD +192 -166
  186. infrahub_testcontainers/container.py +0 -1
  187. infrahub_testcontainers/docker-compose.test.yml +1 -1
  188. infrahub_testcontainers/helpers.py +8 -2
  189. infrahub/message_bus/messages/check_generator_run.py +0 -26
  190. infrahub/message_bus/messages/finalize_validator_execution.py +0 -15
  191. infrahub/message_bus/messages/proposed_change/base_with_diff.py +0 -16
  192. infrahub/message_bus/messages/proposed_change/request_proposedchange_refreshartifacts.py +0 -11
  193. infrahub/message_bus/messages/request_generatordefinition_check.py +0 -20
  194. infrahub/message_bus/messages/request_proposedchange_pipeline.py +0 -23
  195. infrahub/message_bus/operations/check/__init__.py +0 -3
  196. infrahub/message_bus/operations/check/generator.py +0 -156
  197. infrahub/message_bus/operations/finalize/__init__.py +0 -3
  198. infrahub/message_bus/operations/finalize/validator.py +0 -133
  199. infrahub/message_bus/operations/requests/__init__.py +0 -9
  200. infrahub/message_bus/operations/requests/generator_definition.py +0 -140
  201. infrahub/message_bus/operations/requests/proposed_change.py +0 -629
  202. /infrahub/{message_bus/messages/proposed_change → actions}/__init__.py +0 -0
  203. {infrahub_server-1.2.12.dist-info → infrahub_server-1.3.0.dist-info}/LICENSE.txt +0 -0
  204. {infrahub_server-1.2.12.dist-info → infrahub_server-1.3.0.dist-info}/WHEEL +0 -0
  205. {infrahub_server-1.2.12.dist-info → infrahub_server-1.3.0.dist-info}/entry_points.txt +0 -0
@@ -30,8 +30,7 @@ class EnrichedDiffRootsUpsertQuery(Query):
30
30
  query = """
31
31
  UNWIND $diff_root_list AS diff_root_map
32
32
  WITH diff_root_map
33
- CALL {
34
- WITH diff_root_map
33
+ CALL (diff_root_map) {
35
34
  MERGE (diff_root:DiffRoot {uuid: diff_root_map.uuid})
36
35
  SET diff_root.base_branch = diff_root_map.base_branch
37
36
  SET diff_root.diff_branch = diff_root_map.diff_branch
@@ -43,8 +42,7 @@ CALL {
43
42
  WITH DISTINCT diff_root AS diff_root
44
43
  WITH collect(diff_root) AS diff_roots
45
44
  WHERE SIZE(diff_roots) = 2
46
- CALL {
47
- WITH diff_roots
45
+ CALL (diff_roots) {
48
46
  WITH diff_roots[0] AS base_diff_node, diff_roots[1] AS branch_diff_node
49
47
  MERGE (base_diff_node)-[:DIFF_HAS_PARTNER]-(branch_diff_node)
50
48
  SET (base_diff_node).partner_uuid = (branch_diff_node).uuid
@@ -99,7 +97,7 @@ SET
99
97
  diff_node.is_node_kind_migration = node_map.node_properties.is_node_kind_migration,
100
98
  diff_node.path_identifier = node_map.node_properties.path_identifier
101
99
  WITH root_uuid, node_map, diff_node, has_node_conflict
102
- CALL {
100
+ CALL (diff_node) {
103
101
  // -------------------------
104
102
  // delete parent-child relationships for included nodes, they will be added in EnrichedNodesLinkQuery
105
103
  // -------------------------
@@ -108,31 +106,28 @@ CALL {
108
106
  DELETE parent_rel
109
107
  }
110
108
  OPTIONAL MATCH (diff_node)-[:DIFF_HAS_CONFLICT]->(current_node_conflict:DiffConflict)
111
- CALL {
109
+ CALL (diff_node, current_node_conflict, has_node_conflict) {
112
110
  // -------------------------
113
111
  // create a node-level conflict, if necessary
114
112
  // -------------------------
115
113
  WITH diff_node, current_node_conflict, has_node_conflict
116
- WITH diff_node, current_node_conflict, has_node_conflict
117
114
  WHERE current_node_conflict IS NULL AND has_node_conflict = TRUE
118
115
  CREATE (diff_node)-[:DIFF_HAS_CONFLICT]->(:DiffConflict)
119
116
  }
120
- CALL {
117
+ CALL (current_node_conflict, has_node_conflict) {
121
118
  // -------------------------
122
119
  // delete a node-level conflict, if necessary
123
120
  // -------------------------
124
121
  WITH current_node_conflict, has_node_conflict
125
- WITH current_node_conflict, has_node_conflict
126
122
  WHERE current_node_conflict IS NOT NULL AND has_node_conflict = FALSE
127
123
  DETACH DELETE current_node_conflict
128
124
  }
129
125
  WITH root_uuid, node_map, diff_node, has_node_conflict, node_map.conflict_params AS node_conflict_params
130
- CALL {
126
+ CALL (diff_node, has_node_conflict, node_conflict_params) {
131
127
  // -------------------------
132
128
  // set the properties of the node-level conflict, if necessary
133
129
  // -------------------------
134
130
  WITH diff_node, has_node_conflict, node_conflict_params
135
- WITH diff_node, has_node_conflict, node_conflict_params
136
131
  WHERE has_node_conflict = TRUE
137
132
  OPTIONAL MATCH (diff_node)-[:DIFF_HAS_CONFLICT]->(node_conflict:DiffConflict)
138
133
  SET node_conflict = node_conflict_params
@@ -158,8 +153,7 @@ DETACH DELETE attr_to_delete
158
153
  // add attributes for this node
159
154
  // -------------------------
160
155
  WITH DISTINCT diff_node, node_map
161
- CALL {
162
- WITH diff_node, node_map
156
+ CALL (diff_node, node_map) {
163
157
  UNWIND node_map.attributes AS node_attribute
164
158
  MERGE (diff_node)-[:DIFF_HAS_ATTRIBUTE]->(diff_attribute:DiffAttribute {name: node_attribute.node_properties.name})
165
159
  SET diff_attribute = node_attribute.node_properties
@@ -182,15 +176,13 @@ CALL {
182
176
  WITH diff_attr_prop, attr_property
183
177
  OPTIONAL MATCH (diff_attr_prop)-[:DIFF_HAS_CONFLICT]->(current_attr_prop_conflict:DiffConflict)
184
178
  WITH diff_attr_prop, attr_property, current_attr_prop_conflict, (attr_property.conflict_params IS NOT NULL) AS has_prop_conflict
185
- CALL {
186
- WITH has_prop_conflict, current_attr_prop_conflict
179
+ CALL (has_prop_conflict, current_attr_prop_conflict) {
187
180
  WITH has_prop_conflict, current_attr_prop_conflict
188
181
  WHERE has_prop_conflict = FALSE AND current_attr_prop_conflict IS NOT NULL
189
182
  DETACH DELETE current_attr_prop_conflict
190
183
  }
191
- CALL {
192
- WITH has_prop_conflict, diff_attr_prop, attr_property
193
- WITH has_prop_conflict, diff_attr_prop, attr_property
184
+ CALL (has_prop_conflict, diff_attr_prop, attr_property) {
185
+ WITH has_prop_conflict
194
186
  WHERE has_prop_conflict = TRUE
195
187
  MERGE (diff_attr_prop)-[:DIFF_HAS_CONFLICT]->(diff_attr_prop_conflict:DiffConflict)
196
188
  SET diff_attr_prop_conflict = attr_property.conflict_params
@@ -210,9 +202,8 @@ MATCH (:DiffRoot {uuid: root_uuid})-[:DIFF_HAS_NODE]->(diff_node:DiffNode {uuid:
210
202
  // -------------------------
211
203
  // remove stale relationships for this node
212
204
  // -------------------------
213
- CALL {
214
- WITH diff_node, node_map
215
- WITH diff_node, node_map, %(rel_name_list_comp)s AS rel_names
205
+ CALL (diff_node, node_map) {
206
+ WITH %(rel_name_list_comp)s AS rel_names
216
207
  OPTIONAL MATCH (diff_node)-[:DIFF_HAS_RELATIONSHIP]->(rel_to_delete:DiffRelationship)
217
208
  WHERE NOT (rel_to_delete.name IN rel_names)
218
209
  OPTIONAL MATCH (rel_to_delete)-[*..8]->(next_to_delete)
@@ -230,9 +221,8 @@ SET diff_relationship = node_relationship.node_properties
230
221
  // remove stale elements for this relationship group
231
222
  // -------------------------
232
223
  WITH diff_relationship, node_relationship
233
- CALL {
234
- WITH diff_relationship, node_relationship
235
- WITH diff_relationship, node_relationship, %(rel_peers_list_comp)s AS rel_peers
224
+ CALL (diff_relationship, node_relationship) {
225
+ WITH %(rel_peers_list_comp)s AS rel_peers
236
226
  OPTIONAL MATCH (diff_relationship)-[:DIFF_HAS_ELEMENT]->(element_to_delete:DiffRelationshipElement)
237
227
  WHERE NOT (element_to_delete.peer_id IN rel_peers)
238
228
  OPTIONAL MATCH (element_to_delete)-[*..6]->(next_to_delete)
@@ -254,15 +244,13 @@ WITH diff_relationship_element, node_single_relationship
254
244
  OPTIONAL MATCH (diff_relationship_element)-[:DIFF_HAS_CONFLICT]->(current_element_conflict:DiffConflict)
255
245
  WITH diff_relationship_element, node_single_relationship, current_element_conflict,
256
246
  (node_single_relationship.conflict_params IS NOT NULL) AS has_element_conflict
257
- CALL {
258
- WITH has_element_conflict, current_element_conflict
259
- WITH has_element_conflict, current_element_conflict
247
+ CALL (has_element_conflict, current_element_conflict) {
248
+ WITH has_element_conflict
260
249
  WHERE has_element_conflict = FALSE
261
250
  DETACH DELETE current_element_conflict
262
251
  }
263
- CALL {
264
- WITH has_element_conflict, diff_relationship_element, node_single_relationship
265
- WITH has_element_conflict, diff_relationship_element, node_single_relationship
252
+ CALL (has_element_conflict, diff_relationship_element, node_single_relationship) {
253
+ WITH has_element_conflict
266
254
  WHERE has_element_conflict = TRUE
267
255
  MERGE (diff_relationship_element)-[:DIFF_HAS_CONFLICT]->(element_conflict:DiffConflict)
268
256
  SET element_conflict = node_single_relationship.conflict_params
@@ -271,9 +259,8 @@ CALL {
271
259
  // remove stale properties for this relationship element
272
260
  // -------------------------
273
261
  WITH diff_relationship_element, node_single_relationship
274
- CALL {
275
- WITH diff_relationship_element, node_single_relationship
276
- WITH diff_relationship_element, node_single_relationship, %(element_props_list_comp)s AS element_props
262
+ CALL (diff_relationship_element, node_single_relationship) {
263
+ WITH %(element_props_list_comp)s AS element_props
277
264
  OPTIONAL MATCH (diff_relationship_element)-[:DIFF_HAS_PROPERTY]->(property_to_delete:DiffProperty)
278
265
  WHERE NOT (property_to_delete.property_type IN element_props)
279
266
  OPTIONAL MATCH (property_to_delete)-[*..4]->(next_to_delete)
@@ -295,15 +282,14 @@ WITH diff_relationship_property, node_relationship_property
295
282
  OPTIONAL MATCH (diff_relationship_property)-[:DIFF_HAS_CONFLICT]->(diff_relationship_property_conflict:DiffConflict)
296
283
  WITH diff_relationship_property, node_relationship_property, diff_relationship_property_conflict,
297
284
  (node_relationship_property.conflict_params IS NOT NULL) AS has_property_conflict
298
- CALL {
299
- WITH has_property_conflict, diff_relationship_property_conflict
300
- WITH has_property_conflict, diff_relationship_property_conflict
285
+
286
+ CALL (has_property_conflict, diff_relationship_property_conflict) {
287
+ WITH has_property_conflict
301
288
  WHERE has_property_conflict = FALSE
302
289
  DETACH DELETE diff_relationship_property_conflict
303
290
  }
304
- CALL {
305
- WITH has_property_conflict, diff_relationship_property, node_relationship_property
306
- WITH has_property_conflict, diff_relationship_property, node_relationship_property
291
+ CALL (has_property_conflict, diff_relationship_property, node_relationship_property) {
292
+ WITH has_property_conflict
307
293
  WHERE has_property_conflict = TRUE
308
294
  MERGE (diff_relationship_property)-[:DIFF_HAS_CONFLICT]->(property_conflict:DiffConflict)
309
295
  SET property_conflict = node_relationship_property.conflict_params
@@ -481,10 +467,9 @@ WITH keys($parent_node_map) AS child_node_uuids
481
467
  MATCH (diff_root:DiffRoot {uuid: $root_uuid})
482
468
  MATCH (diff_root)-[:DIFF_HAS_NODE]->(child_node:DiffNode)
483
469
  WHERE child_node.uuid IN child_node_uuids
484
- CALL {
485
- WITH diff_root, child_node
486
- WITH diff_root, child_node, $parent_node_map[child_node.uuid] AS sub_map
487
- WITH diff_root, child_node, sub_map, keys(sub_map) AS relationship_names
470
+ CALL (diff_root, child_node) {
471
+ WITH $parent_node_map[child_node.uuid] AS sub_map
472
+ WITH sub_map, keys(sub_map) AS relationship_names
488
473
  MATCH (child_node)-[:DIFF_HAS_RELATIONSHIP]->(diff_rel_group:DiffRelationship)
489
474
  WHERE diff_rel_group.name IN relationship_names
490
475
  WITH diff_root, diff_rel_group, toString(sub_map[diff_rel_group.name]) AS parent_uuid
@@ -46,70 +46,59 @@ WHERE ($diff_id IS NOT NULL AND root.uuid = $diff_id)
46
46
  OR ($tracking_id IS NOT NULL AND root.tracking_id = $tracking_id AND root.diff_branch = $diff_branch_name)
47
47
  MATCH (root)-[:DIFF_HAS_NODE]->(dn:DiffNode)
48
48
  WHERE $node_uuids IS NULL OR dn.uuid IN $node_uuids
49
- CALL {
49
+ CALL (dn) {
50
50
  // ----------------------
51
51
  // handle attribute count updates
52
52
  // ----------------------
53
- WITH dn
54
53
  MATCH (dn)-[:DIFF_HAS_ATTRIBUTE]->(da:DiffAttribute)
55
- CALL {
56
- WITH da
54
+ CALL (da) {
57
55
  OPTIONAL MATCH (da)-[:DIFF_HAS_PROPERTY]->(dp:DiffProperty)-[:DIFF_HAS_CONFLICT]->(dc:DiffConflict)
58
- WITH da, count(dc) AS num_conflicts
56
+ WITH count(dc) AS num_conflicts
59
57
  SET da.num_conflicts = num_conflicts
60
58
  SET da.contains_conflict = (num_conflicts > 0)
61
59
  }
62
- CALL {
63
- WITH da
60
+ CALL (da) {
64
61
  OPTIONAL MATCH (da)-[:DIFF_HAS_PROPERTY]->(dp:DiffProperty {action: "added"})
65
- WITH da, count(dp.action) AS num_added
62
+ WITH count(dp.action) AS num_added
66
63
  SET da.num_added = num_added
67
64
  }
68
- CALL {
69
- WITH da
65
+ CALL (da) {
70
66
  OPTIONAL MATCH (da)-[:DIFF_HAS_PROPERTY]->(dp:DiffProperty {action: "updated"})
71
- WITH da, count(dp.action) AS num_updated
67
+ WITH count(dp.action) AS num_updated
72
68
  SET da.num_updated = num_updated
73
69
  }
74
- CALL {
75
- WITH da
70
+ CALL (da) {
76
71
  OPTIONAL MATCH (da)-[:DIFF_HAS_PROPERTY]->(dp:DiffProperty {action: "removed"})
77
- WITH da, count(dp.action) AS num_removed
72
+ WITH count(dp.action) AS num_removed
78
73
  SET da.num_removed = num_removed
79
74
  }
80
75
  }
81
- CALL {
82
- WITH dn
76
+ CALL (dn) {
83
77
  MATCH (dn)-[:DIFF_HAS_RELATIONSHIP]->(dr:DiffRelationship)
84
- CALL {
78
+ CALL (dr) {
85
79
  // ----------------------
86
80
  // handle relationship element count updates
87
81
  // ----------------------
88
- WITH dr
89
82
  MATCH (dr)-[:DIFF_HAS_ELEMENT]->(dre:DiffRelationshipElement)
90
- CALL {
91
- WITH dre
83
+ CALL (dre) {
92
84
  OPTIONAL MATCH (dre)-[*..4]->(dc:DiffConflict)
93
- WITH dre, count(dc) AS num_conflicts
85
+ WITH count(dc) AS num_conflicts
94
86
  SET dre.num_conflicts = num_conflicts
95
87
  SET dre.contains_conflict = (num_conflicts > 0)
96
88
  }
97
- CALL {
98
- WITH dre
89
+ CALL (dre) {
99
90
  OPTIONAL MATCH (dre)-[:DIFF_HAS_PROPERTY]->(dp:DiffProperty {action: "added"})
100
- WITH dre, count(dp.action) AS num_added
91
+ WITH count(dp.action) AS num_added
101
92
  SET dre.num_added = num_added
102
93
  }
103
- CALL {
104
- WITH dre
94
+ CALL (dre) {
105
95
  OPTIONAL MATCH (dre)-[:DIFF_HAS_PROPERTY]->(dp:DiffProperty {action: "updated"})
106
- WITH dre, count(dp.action) AS num_updated
96
+ WITH count(dp.action) AS num_updated
107
97
  SET dre.num_updated = num_updated
108
98
  }
109
- CALL {
110
- WITH dre
99
+ CALL (dre) {
111
100
  OPTIONAL MATCH (dre)-[:DIFF_HAS_PROPERTY]->(dp:DiffProperty {action: "removed"})
112
- WITH dre, count(dp.action) AS num_removed
101
+ WITH count(dp.action) AS num_removed
113
102
  SET dre.num_removed = num_removed
114
103
  }
115
104
  }
@@ -121,22 +110,19 @@ CALL {
121
110
  SET dr.num_conflicts = num_conflicts
122
111
  SET dr.contains_conflict = (num_conflicts > 0)
123
112
  WITH dr
124
- CALL {
125
- WITH dr
113
+ CALL (dr) {
126
114
  OPTIONAL MATCH (dr)-[:DIFF_HAS_ELEMENT]->(dre:DiffRelationshipElement {action: "added"})
127
- WITH dr, count(dre.action) AS num_added
115
+ WITH count(dre.action) AS num_added
128
116
  SET dr.num_added = num_added
129
117
  }
130
- CALL {
131
- WITH dr
118
+ CALL (dr) {
132
119
  OPTIONAL MATCH (dr)-[:DIFF_HAS_ELEMENT]->(dre:DiffRelationshipElement {action: "updated"})
133
- WITH dr, count(dre.action) AS num_updated
120
+ WITH count(dre.action) AS num_updated
134
121
  SET dr.num_updated = num_updated
135
122
  }
136
- CALL {
137
- WITH dr
123
+ CALL (dr) {
138
124
  OPTIONAL MATCH (dr)-[:DIFF_HAS_ELEMENT]->(dre:DiffRelationshipElement {action: "removed"})
139
- WITH dr, count(dre.action) AS num_removed
125
+ WITH count(dre.action) AS num_removed
140
126
  SET dr.num_removed = num_removed
141
127
  }
142
128
  }
@@ -189,19 +175,16 @@ WHERE $node_uuids IS NULL OR dn.uuid IN $node_uuids
189
175
  // handle node count updates
190
176
  // ----------------------
191
177
  WITH root, dn, coalesce(dn.num_conflicts, 0) AS previous_num_conflicts
192
- CALL {
178
+ CALL (dn) {
193
179
  // ----------------------
194
180
  // handle node num_conflicts update
195
181
  // ----------------------
196
- WITH dn
197
182
  OPTIONAL MATCH (dn)-[:DIFF_HAS_ATTRIBUTE]->(da:DiffAttribute {contains_conflict: TRUE})
198
183
  RETURN sum(da.num_conflicts) AS num_conflicts
199
184
  UNION ALL
200
- WITH dn
201
185
  OPTIONAL MATCH (dn)-[:DIFF_HAS_RELATIONSHIP]->(dr:DiffRelationship {contains_conflict: TRUE})
202
186
  RETURN sum(dr.num_conflicts) AS num_conflicts
203
187
  UNION ALL
204
- WITH dn
205
188
  OPTIONAL MATCH (dn)-[:DIFF_HAS_CONFLICT]->(dc:DiffConflict)
206
189
  RETURN count(dc) AS num_conflicts
207
190
  }
@@ -209,17 +192,16 @@ WITH root, dn, previous_num_conflicts, sum(num_conflicts) AS updated_num_conflic
209
192
  SET dn.num_conflicts = updated_num_conflicts
210
193
  SET dn.contains_conflict = (updated_num_conflicts > 0)
211
194
  WITH root, dn, updated_num_conflicts - previous_num_conflicts AS num_conflicts_delta
212
- CALL {
195
+ CALL (dn) {
213
196
  // ----------------------
214
197
  // handle node added/updated/removed updates
215
198
  // ----------------------
216
- WITH dn
217
199
  OPTIONAL MATCH (dn)-[:DIFF_HAS_ATTRIBUTE]->(da:DiffAttribute)
218
- WITH dn, collect(da.action) AS attr_actions
200
+ WITH collect(da.action) AS attr_actions
219
201
  OPTIONAL MATCH (dn)-[:DIFF_HAS_RELATIONSHIP]->(dr:DiffRelationship)
220
- WITH dn, attr_actions, collect(dr.action) AS rel_actions
221
- WITH dn, attr_actions + rel_actions AS actions
222
- WITH dn, reduce(counts = [0,0,0], a IN actions |
202
+ WITH attr_actions, collect(dr.action) AS rel_actions
203
+ WITH attr_actions + rel_actions AS actions
204
+ WITH reduce(counts = [0,0,0], a IN actions |
223
205
  CASE
224
206
  WHEN a = "added" THEN [counts[0] + 1, counts[1], counts[2]]
225
207
  WHEN a = "updated" THEN [counts[0], counts[1] + 1, counts[2]]
@@ -227,7 +209,7 @@ CALL {
227
209
  ELSE counts
228
210
  END
229
211
  ) AS action_counts
230
- WITH dn, action_counts[0] AS num_added, action_counts[1] AS num_updated, action_counts[2] AS num_removed
212
+ WITH action_counts[0] AS num_added, action_counts[1] AS num_updated, action_counts[2] AS num_removed
231
213
  SET dn.num_added = num_added
232
214
  SET dn.num_updated = num_updated
233
215
  SET dn.num_removed = num_removed
@@ -236,8 +218,7 @@ CALL {
236
218
  // handle conflict updates for parent nodes
237
219
  // ----------------------
238
220
  WITH root, dn, num_conflicts_delta
239
- CALL {
240
- WITH dn, num_conflicts_delta
221
+ CALL (dn, num_conflicts_delta) {
241
222
  OPTIONAL MATCH (dn)-[:DIFF_HAS_RELATIONSHIP|DIFF_HAS_NODE*1..]->(parent_node:DiffNode)
242
223
  SET parent_node.num_conflicts = parent_node.num_conflicts + num_conflicts_delta
243
224
  SET parent_node.contains_conflict = (parent_node.num_conflicts > 0)
@@ -246,8 +227,7 @@ CALL {
246
227
  // handle root count updates
247
228
  // ----------------------
248
229
  WITH root, sum(num_conflicts_delta) AS total_conflicts_delta
249
- CALL {
250
- WITH root, total_conflicts_delta
230
+ CALL (root, total_conflicts_delta) {
251
231
  SET root.num_conflicts = coalesce(root.num_conflicts, 0) + total_conflicts_delta
252
232
  SET root.contains_conflict = root.num_conflicts > 0
253
233
  WITH root
@@ -37,7 +37,6 @@ class EnrichedDiffTimeRangeQuery(Query):
37
37
  "from_time": self.from_time.to_string(),
38
38
  "to_time": self.to_time.to_string(),
39
39
  }
40
- # ruff: noqa: E501
41
40
  query = """
42
41
  // get the roots of all diffs in the query
43
42
  MATCH (diff_root:DiffRoot)
@@ -377,6 +377,10 @@ class DiffRepository:
377
377
  await query.execute(db=self.db)
378
378
  return query.get_summary()
379
379
 
380
+ async def delete_all_diff_roots(self) -> None:
381
+ query = await EnrichedDiffDeleteQuery.init(db=self.db)
382
+ await query.execute(db=self.db)
383
+
380
384
  async def delete_diff_roots(self, diff_root_uuids: list[str]) -> None:
381
385
  query = await EnrichedDiffDeleteQuery.init(db=self.db, enriched_diff_root_uuids=diff_root_uuids)
382
386
  await query.execute(db=self.db)
infrahub/core/manager.py CHANGED
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ from copy import copy
3
4
  from functools import reduce
4
5
  from typing import TYPE_CHECKING, Any, Iterable, Literal, TypeVar, overload
5
6
 
@@ -1339,22 +1340,24 @@ class NodeManager:
1339
1340
  nodes: list[Node],
1340
1341
  branch: Branch | str | None = None,
1341
1342
  at: Timestamp | str | None = None,
1343
+ cascade_delete: bool = True,
1342
1344
  ) -> list[Node]:
1343
1345
  """Returns list of deleted nodes because of cascading deletes"""
1344
1346
  branch = await registry.get_branch(branch=branch, db=db)
1345
- node_delete_validator = NodeDeleteValidator(db=db, branch=branch)
1346
- ids_to_delete = await node_delete_validator.get_ids_to_delete(nodes=nodes, at=at)
1347
- node_ids = {node.get_id() for node in nodes}
1348
- missing_ids_to_delete = ids_to_delete - node_ids
1349
- if missing_ids_to_delete:
1350
- node_map = await cls.get_many(db=db, ids=list(missing_ids_to_delete), branch=branch, at=at)
1351
- nodes += list(node_map.values())
1352
- deleted_nodes = []
1353
- for node in nodes:
1347
+ nodes_to_delete = copy(nodes)
1348
+ if cascade_delete:
1349
+ node_delete_validator = NodeDeleteValidator(db=db, branch=branch)
1350
+ ids_to_delete = await node_delete_validator.get_ids_to_delete(nodes=nodes, at=at)
1351
+ node_ids = {node.get_id() for node in nodes}
1352
+ missing_ids_to_delete = ids_to_delete - node_ids
1353
+ if missing_ids_to_delete:
1354
+ node_map = await cls.get_many(db=db, ids=list(missing_ids_to_delete), branch=branch, at=at)
1355
+ nodes_to_delete += list(node_map.values())
1356
+
1357
+ for node in nodes_to_delete:
1354
1358
  await node.delete(db=db, at=at)
1355
- deleted_nodes.append(node)
1356
1359
 
1357
- return deleted_nodes
1360
+ return nodes_to_delete
1358
1361
 
1359
1362
 
1360
1363
  def _get_cardinality_one_identifiers_by_kind(
@@ -26,8 +26,7 @@ class Migration003Query01(Query):
26
26
  query = """
27
27
  MATCH path = (av2:AttributeValue)-[:HAS_VALUE]-(:Attribute {name: "optional"})-[:HAS_ATTRIBUTE]-(n:SchemaRelationship)-[:HAS_ATTRIBUTE]-(:Attribute {name: "kind"})-[:HAS_VALUE]-(av1:AttributeValue)
28
28
  WHERE av1.value = "Parent" AND av2.value = true AND all(r IN relationships(path) WHERE ( %(filters)s ))
29
- CALL {
30
- WITH n
29
+ CALL (n) {
31
30
  MATCH path22 = (av22:AttributeValue)-[r22:HAS_VALUE]-(a2:Attribute {name: "optional"})-[:HAS_ATTRIBUTE]-(n:SchemaRelationship)-[:HAS_ATTRIBUTE]-(:Attribute {name:"kind"})-[:HAS_VALUE]-(av11:AttributeValue)
32
31
  WHERE av11.value = "Parent" AND av22.value = true AND all(r IN relationships(path22) WHERE ( %(filters)s ))
33
32
  RETURN av22 as av2_sub, r22, a2, path22 as path2
@@ -61,7 +61,7 @@ class Migration012RenameTypeAttributeData(AttributeRenameQuery):
61
61
  def render_match(self) -> str:
62
62
  query = """
63
63
  // Find all the active nodes
64
- CALL {
64
+ CALL () {
65
65
  MATCH (node:%(node_kind)s)
66
66
  WHERE exists((node)-[:HAS_ATTRIBUTE]-(:Attribute { name: $prev_attr.name }))
67
67
  AND NOT exists((node)-[:HAS_ATTRIBUTE]-(:Attribute { name: $new_attr.name }))
@@ -77,7 +77,6 @@ class Migration013ConvertCoreRepositoryWithCred(Query):
77
77
 
78
78
  self.params["rel_identifier"] = "gitrepository__credential"
79
79
 
80
- # ruff: noqa: E501
81
80
  query = """
82
81
  // --------------------------------
83
82
  // Identify the git repositories to convert
@@ -98,8 +97,7 @@ class Migration013ConvertCoreRepositoryWithCred(Query):
98
97
  // --------------------------------
99
98
  MATCH (git_repo)-[:HAS_ATTRIBUTE]-(git_attr_name:Attribute)-[:HAS_VALUE]->(git_name_value:AttributeValue)
100
99
  WHERE git_attr_name.name = "name"
101
- CALL {
102
- WITH git_repo
100
+ CALL (git_repo) {
103
101
  MATCH path1 = (git_repo)-[r1:HAS_ATTRIBUTE]-(git_attr_name2:Attribute)-[r2:HAS_VALUE]->(git_name_value2:AttributeValue)
104
102
  WHERE git_attr_name2.name = "name"
105
103
  AND all(r IN relationships(path1) WHERE %(filters)s)
@@ -195,7 +193,6 @@ class Migration013ConvertCoreRepositoryWithoutCred(Query):
195
193
 
196
194
  self.params["current_time"] = self.at.to_string()
197
195
 
198
- # ruff: noqa: E501
199
196
  query = """
200
197
  // --------------------------------
201
198
  // Identify the git repositories to convert
@@ -204,8 +201,7 @@ class Migration013ConvertCoreRepositoryWithoutCred(Query):
204
201
  WHERE a.name in ["username", "password"]
205
202
  AND av.value = "NULL"
206
203
  AND all(r IN relationships(path) WHERE %(filters)s AND r.status = "active")
207
- CALL {
208
- WITH node
204
+ CALL (node) {
209
205
  MATCH (root:Root)<-[r:IS_PART_OF]-(node)
210
206
  WHERE %(filters)s
211
207
  RETURN node as n1, r as r1
@@ -31,6 +31,5 @@ class Migration015(ArbitraryMigration):
31
31
  component_registry = get_component_registry()
32
32
  diff_repo = await component_registry.get_component(DiffRepository, db=db, branch=default_branch)
33
33
 
34
- diff_roots = await diff_repo.get_roots_metadata()
35
- await diff_repo.delete_diff_roots(diff_root_uuids=[d.uuid for d in diff_roots])
34
+ await diff_repo.delete_all_diff_roots()
36
35
  return MigrationResult()
@@ -31,6 +31,5 @@ class Migration016(ArbitraryMigration):
31
31
  component_registry = get_component_registry()
32
32
  diff_repo = await component_registry.get_component(DiffRepository, db=db, branch=default_branch)
33
33
 
34
- diff_roots = await diff_repo.get_roots_metadata()
35
- await diff_repo.delete_diff_roots(diff_root_uuids=[d.uuid for d in diff_roots])
34
+ await diff_repo.delete_all_diff_roots()
36
35
  return MigrationResult()
@@ -97,8 +97,7 @@ class DeleteNodesRelsQuery(Query):
97
97
  // - on deleted edge branch
98
98
  // - or on any branch and deleted node is agnostic
99
99
  // - or deleted node is aware and rel is agnostic
100
- CALL {
101
- WITH rel, deleted_edge
100
+ CALL (rel, deleted_edge) {
102
101
  OPTIONAL MATCH (rel)-[peer_active_edge {status: "active"}]-(peer_1)
103
102
  WHERE (peer_active_edge.branch = deleted_edge.branch OR (rel.branch_support <> $branch_agnostic AND deleted_edge.branch = $global_branch))
104
103
  AND peer_active_edge.to IS NULL
@@ -160,62 +159,52 @@ class DeleteNodesRelsQuery(Query):
160
159
  // Below CALL subqueries are called once for each rel-peer_2 pair for which we want to create a deleted edge.
161
160
  // Note that with current infrahub relationships edges design, only one of this CALL should be matched per pair.
162
161
 
163
- CALL {
164
- WITH rel, peer_2, branch, branch_level, deleted_time
162
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
165
163
  MATCH (rel)-[:IS_RELATED]->(peer_2)
166
164
  MERGE (rel)-[:IS_RELATED {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]->(peer_2)
167
165
  }
168
166
 
169
- CALL {
170
- WITH rel, peer_2, branch, branch_level, deleted_time
167
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
171
168
  MATCH (rel)-[:IS_PROTECTED]->(peer_2)
172
169
  MERGE (rel)-[:IS_PROTECTED {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]->(peer_2)
173
170
  }
174
171
 
175
- CALL {
176
- WITH rel, peer_2, branch, branch_level, deleted_time
172
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
177
173
  MATCH (rel)-[:IS_VISIBLE]->(peer_2)
178
174
  MERGE (rel)-[:IS_VISIBLE {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]->(peer_2)
179
175
  }
180
176
 
181
- CALL {
182
- WITH rel, peer_2, branch, branch_level, deleted_time
177
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
183
178
  MATCH (rel)-[:HAS_OWNER]->(peer_2)
184
179
  MERGE (rel)-[:HAS_OWNER {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]->(peer_2)
185
180
  }
186
181
 
187
- CALL {
188
- WITH rel, peer_2, branch, branch_level, deleted_time
182
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
189
183
  MATCH (rel)-[:HAS_SOURCE]->(peer_2)
190
184
  MERGE (rel)-[:HAS_SOURCE {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]->(peer_2)
191
185
  }
192
186
 
193
- CALL {
194
- WITH rel, peer_2, branch, branch_level, deleted_time
187
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
195
188
  MATCH (rel)<-[:IS_RELATED]-(peer_2)
196
189
  MERGE (rel)<-[:IS_RELATED {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]-(peer_2)
197
190
  }
198
191
 
199
- CALL {
200
- WITH rel, peer_2, branch, branch_level, deleted_time
192
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
201
193
  MATCH (rel)<-[:IS_PROTECTED]-(peer_2)
202
194
  MERGE (rel)<-[:IS_PROTECTED {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]-(peer_2)
203
195
  }
204
196
 
205
- CALL {
206
- WITH rel, peer_2, branch, branch_level, deleted_time
197
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
207
198
  MATCH (rel)<-[:IS_VISIBLE]-(peer_2)
208
199
  MERGE (rel)<-[:IS_VISIBLE {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]-(peer_2)
209
200
  }
210
201
 
211
- CALL {
212
- WITH rel, peer_2, branch, branch_level, deleted_time
202
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
213
203
  MATCH (rel)<-[:HAS_OWNER]-(peer_2)
214
204
  MERGE (rel)<-[:HAS_OWNER {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]-(peer_2)
215
205
  }
216
206
 
217
- CALL {
218
- WITH rel, peer_2, branch, branch_level, deleted_time
207
+ CALL (rel, peer_2, branch, branch_level, deleted_time) {
219
208
  MATCH (rel)<-[:HAS_SOURCE]-(peer_2)
220
209
  MERGE (rel)<-[:HAS_SOURCE {status: "deleted", branch: branch, branch_level: branch_level, from: deleted_time}]-(peer_2)
221
210
  }
@@ -33,8 +33,7 @@ WHERE num_duplicate_edges > 1
33
33
  // -------------------
34
34
  WITH DISTINCT a, branch, branch_level, status, from, to, attr_val, attr_default
35
35
  WITH attr_val, attr_default, collect([a, branch, branch_level, status, from, to]) AS details_list
36
- CALL {
37
- WITH attr_val, attr_default
36
+ CALL (attr_val, attr_default) {
38
37
  MATCH (av:AttributeValue {value: attr_val, is_default: attr_default})
39
38
  RETURN av AS the_one_av
40
39
  ORDER by %(id_func)s(av) ASC
@@ -53,11 +52,10 @@ WITH a, branch, status, from, to, attr_val, attr_default, %(id_func)s(fresh_e) A
53
52
  // -------------------
54
53
  // get the identical edges for a given set of Attribute node, edge properties, AttributeValue.value
55
54
  // -------------------
56
- CALL {
55
+ CALL (a, branch, status, from, to, attr_val, attr_default, e_id_to_keep) {
57
56
  // -------------------
58
57
  // delete the duplicate edges a given set of Attribute node, edge properties, AttributeValue.value
59
58
  // -------------------
60
- WITH a, branch, status, from, to, attr_val, attr_default, e_id_to_keep
61
59
  MATCH (a)-[e:HAS_VALUE]->(av:AttributeValue {value: attr_val, is_default: attr_default})
62
60
  WHERE %(id_func)s(e) <> e_id_to_keep
63
61
  AND e.branch = branch AND e.status = status AND e.from = from
@@ -99,8 +97,7 @@ WITH DISTINCT a, branch, branch_level, status, from, to, b
99
97
  CREATE (a)-[fresh_e:%(edge_type)s {branch: branch, branch_level: branch_level, status: status, from: from}]->(b)
100
98
  SET fresh_e.to = to
101
99
  WITH a, branch, status, from, to, b, %(id_func)s(fresh_e) AS e_id_to_keep
102
- CALL {
103
- WITH a, branch, status, from, to, b, e_id_to_keep
100
+ CALL (a, branch, status, from, to, b, e_id_to_keep) {
104
101
  MATCH (a)-[e:%(edge_type)s]->(b)
105
102
  WHERE %(id_func)s(e) <> e_id_to_keep
106
103
  AND e.branch = branch AND e.status = status AND e.from = from
@@ -24,8 +24,7 @@ class SetMissingHierarchyQuery(Query):
24
24
  WITH r.default_branch AS default_branch
25
25
  MATCH (n:Node)-[main_e:IS_RELATED {branch: default_branch}]-(rel:Relationship)
26
26
  WHERE main_e.hierarchy IS NULL
27
- CALL {
28
- WITH n, main_e, rel
27
+ CALL (n, main_e, rel) {
29
28
  MATCH (n)-[branch_e:IS_RELATED]-(rel)
30
29
  WHERE branch_e.hierarchy IS NOT NULL
31
30
  AND branch_e.branch <> main_e.branch
@@ -52,7 +52,7 @@ class DedupCardinalityOneRelsQuery(Query):
52
52
  # of a one-to-many BIDIR relationship.
53
53
  query = """
54
54
 
55
- CALL {
55
+ CALL () {
56
56
  MATCH (rel_node: Relationship)-[edge:IS_RELATED]->(n: Node)<-[edge_2:IS_RELATED]-(rel_node_2: Relationship {name: rel_node.name})
57
57
  WHERE rel_node.name in $rel_one_identifiers_inbound[n.kind]
58
58
  AND edge.branch = edge_2.branch
@@ -64,7 +64,7 @@ class DedupCardinalityOneRelsQuery(Query):
64
64
  DETACH DELETE rel_node
65
65
  }
66
66
 
67
- CALL {
67
+ CALL () {
68
68
  MATCH (rel_node_3: Relationship)<-[edge_3:IS_RELATED]-(n: Node)-[edge_4:IS_RELATED]->(rel_node_4: Relationship {name: rel_node_3.name})
69
69
  WHERE rel_node_3.name in $rel_one_identifiers_outbound[n.kind]
70
70
  AND edge_3.branch = edge_4.branch