feat: allow setting a query comment through a context value #1122
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an enhancement to recently merged comment functionality. This implementation preserves the current functionality, but allows a comment to be set at the time a query is executed.
This can be used like so:
Which, like the
Comment()
API will produce:I should note that in this implementation, if a comment is set through a context, it takes precedence over one set on a query using the
Comment()
API. If the opposite precedence makes more sense, I'm happy to change this.I know there was some discussion about supporting multiple comments - I'm happy to add some support for that if it's desirable. I think there's good reason to support both mechanisms and have them play nicely together, but maybe that should be discussed separately. For example, the idea of adding a
.Comment("descriptive query name")
to individual queries, but then being able to combine that with a context that provides a trace ID so that all queries made as part of a given request can be identified. In this case, I would propose that any comment set on the context appear first in the query followed by any set using theComment()
method.