-
-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow setting a query comment through a context value #1122
Conversation
350c8dd
to
9870802
Compare
Passing comments through context is a good idea, thank you for your contribution.
|
I wouldn't be opposed to merging them - I think there is definitely value there. If I remember correctly, one of the other discussions raised some questions about comment order if multiple comments are specified. So, I think we just need to decide what the proper behavior should be.
Yes, I think that would be a reasonable way to refactor and DRY up this addition and the existing implementation. Happy to take a pass at that if you'd like. |
I respect your opinion on merging or replacing. |
I finally had some time to look into this, and it turns out to be a bit more complicated than I realized. the
Given the above, I think my suggestion would be to stick with the current implementation where the context comment replaces the comment set on the query/provides an alternate way to set a comment. We can always add support for multiple comments or merging the two if there's demand, but it doesn't seem like anyone is asking for that yet. |
9870802
to
1596842
Compare
I’m sorry for not checking the logic of beforeQuery, which ended up wasting your time. |
Signed-off-by: Kyle McCullough <[email protected]>
1596842
to
9f5ccfe
Compare
No problem :) |
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.