@@ -312,24 +312,37 @@ allSerializedDependenciesOfCausalCursor cid = do
312
312
JOIN types typ ON atc.component_hash_id = typ.component_hash_id
313
313
JOIN type_local_component_references ref ON typ.id = ref.type_id
314
314
)
315
- ) SELECT bytes.bytes, tc.causal_hash
316
- FROM transitive_causals tc
317
- JOIN serialized_causals sc ON tc.causal_id = sc.causal_id
315
+ )
316
+ (SELECT bytes.bytes, ch.base32
317
+ FROM transitive_components tc
318
+ JOIN serialized_components sc ON tc.component_hash_id = sc.component_hash_id
318
319
JOIN bytes ON sc.bytes_id = bytes.id
320
+ JOIN component_hashes ch ON tc.component_hash_id = ch.id
321
+ -- Reverse the ordering so deeper components come first
322
+ ORDER BY row_number() OVER () DESC
323
+ )
319
324
UNION ALL
320
- SELECT bytes.bytes, an.namespace_hash
321
- FROM all_namespaces an
322
- JOIN serialized_namespaces sn ON an.namespace_hash_id = sn.namespace_hash_id
323
- JOIN bytes ON sn.bytes_id = bytes.id
324
- UNION ALL
325
- SELECT bytes.bytes, ap.patch_hash
325
+ (SELECT bytes.bytes, ap.patch_hash
326
326
FROM all_patches ap
327
327
JOIN serialized_patches sp ON ap.patch_id = sp.patch_id
328
328
JOIN bytes ON sp.bytes_id = bytes.id
329
+ -- Reverse the ordering so deeper components come first
330
+ ORDER BY row_number() OVER () DESC
331
+ )
329
332
UNION ALL
330
- SELECT bytes.bytes, ch.base32
331
- FROM transitive_components tc
332
- JOIN serialized_components sc ON tc.component_hash_id = sc.component_hash_id
333
+ (SELECT bytes.bytes, an.namespace_hash
334
+ FROM all_namespaces an
335
+ JOIN serialized_namespaces sn ON an.namespace_hash_id = sn.namespace_hash_id
336
+ JOIN bytes ON sn.bytes_id = bytes.id
337
+ -- Reverse the ordering so deeper components come first
338
+ ORDER BY row_number() OVER () DESC
339
+ )
340
+ UNION ALL
341
+ (SELECT bytes.bytes, tc.causal_hash
342
+ FROM transitive_causals tc
343
+ JOIN serialized_causals sc ON tc.causal_id = sc.causal_id
333
344
JOIN bytes ON sc.bytes_id = bytes.id
334
- JOIN component_hashes ch ON tc.component_hash_id = ch.id
345
+ -- Reverse the ordering so deeper components come first
346
+ ORDER BY row_number() OVER () DESC
347
+ )
335
348
|]
0 commit comments