@@ -50,7 +50,7 @@ allSerializedDependenciesOfCausalCursor cid exceptCausalHashes = do
5050 JOIN component_hashes ch ON dh.hash = ch.base32
5151 |]
5252 cursor <-
53- PGCursor. newRowCursor
53+ PGCursor. newRowCursor @ ( CBORBytes TempEntity , Hash32 , Maybe Int32 )
5454 " serialized_entities"
5555 [sql |
5656 WITH RECURSIVE transitive_causals(causal_id, causal_hash, causal_namespace_hash_id) AS (
@@ -178,32 +178,44 @@ allSerializedDependenciesOfCausalCursor cid exceptCausalHashes = do
178178 JOIN serialized_components sc ON sc.user_id = #{ownerUserId} AND tc.component_hash_id = sc.component_hash_id
179179 JOIN bytes ON sc.bytes_id = bytes.id
180180 JOIN component_hashes ch ON tc.component_hash_id = ch.id
181- JOIN component_depth cd ON ch.id = cd.component_hash_id
181+ LEFT JOIN component_depth cd ON ch.id = cd.component_hash_id
182182 )
183183 UNION ALL
184184 (SELECT bytes.bytes, ap.patch_hash, pd.depth
185185 FROM all_patches ap
186186 JOIN serialized_patches sp ON ap.patch_id = sp.patch_id
187187 JOIN bytes ON sp.bytes_id = bytes.id
188- JOIN patch_depth pd ON ap.patch_id = pd.patch_id
188+ LEFT JOIN patch_depth pd ON ap.patch_id = pd.patch_id
189189 )
190190 UNION ALL
191191 (SELECT bytes.bytes, an.namespace_hash, nd.depth
192192 FROM all_namespaces an
193193 JOIN serialized_namespaces sn ON an.namespace_hash_id = sn.namespace_hash_id
194194 JOIN bytes ON sn.bytes_id = bytes.id
195- JOIN namespace_depth nd ON an.namespace_hash_id = nd.namespace_hash_id
195+ LEFT JOIN namespace_depth nd ON an.namespace_hash_id = nd.namespace_hash_id
196196 )
197197 UNION ALL
198198 (SELECT bytes.bytes, tc.causal_hash, cd.depth
199199 FROM transitive_causals tc
200200 JOIN serialized_causals sc ON tc.causal_id = sc.causal_id
201201 JOIN bytes ON sc.bytes_id = bytes.id
202- JOIN causal_depth cd ON tc.causal_id = cd.causal_id
202+ LEFT JOIN causal_depth cd ON tc.causal_id = cd.causal_id
203203 )
204- ORDER BY depth ASC
204+ -- Re-add this once the migration is done.
205+ -- Put them in dependency order, nulls come first because we want to bail and
206+ -- report an error
207+ -- if we somehow are missing a depth.
208+ -- ORDER BY depth ASC NULLS FIRST
205209 |]
206- pure cursor
210+ -- pure
211+ -- ( cursor <&> \(bytes, hash, depth) -> case depth of
212+ -- -- This should never happen, but is a sanity check in case we're missing a depth.
213+ -- -- Better than silently omitting a required result.
214+ -- Nothing -> error $ "allSerializedDependenciesOfCausalCursor: Missing depth for entity: " <> show hash
215+ -- Just _ -> (bytes, hash)
216+ -- )
217+ pure
218+ (cursor <&> \ (bytes, hash, _depth) -> (bytes, hash))
207219
208220spineAndLibDependenciesOfCausalCursor :: CausalId -> CodebaseM e (PGCursor (Hash32 , IsCausalSpine , IsLibRoot ))
209221spineAndLibDependenciesOfCausalCursor cid = do
0 commit comments