Skip to content

Commit

Permalink
patch decoding error when quering non-existent volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
tayloraswift committed Oct 23, 2024
1 parent a3da5b0 commit 1d75d42
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Sources/UnidocQueries/Volumes/Unidoc.VertexQuery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,21 @@ extension Unidoc.VertexQuery:Mongo.PipelineQuery
}

pipeline[stage: .facet, using: FacetOne.CodingKey.self] { self.build(facet: &$0) }
// We need this because `$facet` injects a document even if the pipeline didn’t match
// a principal volume.
pipeline[stage: .unwind] = FacetTwo[.carryover]
pipeline[stage: .set, using: FacetOne.CodingKey.self]
{
$0[.principalOnly] { $0[.first] = FacetOne[.principalOnly] }
}
pipeline[stage: .replaceWith]
{
$0[.mergeObjects]
{
// Carried-over fields come second, because we want to keep the cleaned-up
// volume metadata documents instead of the raw ones.
$0[.concatArrays] = (FacetOne[.principalOnly], FacetOne[.carryover])
$0[+] = FacetOne[.principalOnly]
$0[+] = FacetTwo[.carryover]
}
}

Expand Down

0 comments on commit 1d75d42

Please sign in to comment.