-
Notifications
You must be signed in to change notification settings - Fork 140
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
Add an API for writing inline annotations that apply to a subset of queries #81
Conversation
Note: the current build failures appear to be in the test setup itself, and are occurring on |
Hey @mattyoho can you rebase with master? I fixed the Travis tests to run and to test against 5.2 additionally. |
5fd9ce3
to
1d409cb
Compare
@eileencodes Awesome, thank you! Rebased. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, i am ready to merge it when you are
@@ -30,6 +30,11 @@ def self.construct_comment | |||
ret | |||
end | |||
|
|||
def self.construct_inline_comment | |||
return nil if inline_annotations.none? | |||
escape_sql_comment(inline_annotations.join) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for escaping it
Awesome. I think this diff is ready. 👍 |
new version released also https://rubygems.org/gems/marginalia/versions/1.7.0 |
Great, thanks! |
Follow up to basecamp#81. See also: 5d130bf.
Marginalia's request-level or job-level annotations are great, but in some cases it's valuable to add annotations to a specific subset of queries issued during a request or other context.
Since Marginalia is already hooked into annotating the SQL string passed into the database adapter level, it provides a good chokepoint for that functionality as well.
This patch implements a new API to add that ability. The following code:
will issue this query:
Any queries issues inside the
with_annotation
block will include the inline comment.Nesting
with_annotation
blocks will concatenate the comment strings.yields:
/cc @arthurnn