Skip to content

search: factor out query mapping for search contexts

Administrator requested to merge backend-integration/rvt/qc-3 into main

Created by: rvantonder

Stacked on https://github.com/sourcegraph/sourcegraph/pull/29951

This factors out the core query transformation parts of substituteSearchContexts previously in search.go. At the cost of passing a callback, we can embed the substitution in the query plan pipeline. This grants:

  • easier to test the core substitution because it abstracts away ctx/db deps
  • easier to promote this query step to the default pipeline once we're ready to turn off the feature flag
  • avoids redoing work by taking the existing plan, unrolling it, and rebuilding it with a bunch of function calls to plan/DNF

It was a bit difficult to spot the possibility of this simplification when I reviewed the original PR, so I couldn't recommend it at the time, sorry about that. The heavy dependence on query. functions and the fact that we did a lot of work post-query-pipeline had me thinking there had to be some way like this to achieve something more separable.

Merge request reports

Loading