-
Notifications
You must be signed in to change notification settings - Fork 12.1k
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
Dashboard: Support additional variable format options (singlequote, doublequote, sqlstring) #21622
Conversation
Could you please fill in the section 'What this PR does / why we need it' in the PR template? |
@aknuds1 Thanks for your quick response, PR template has been update. |
There should be custom format functions in the Postgres and MySQL datasources I’m that does this I think |
Thanks @torkelo . It is not easy to decide which variable should be quoted/escaped in datasources plugins. For example: |
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.
It is nice to have examples in the docs... but I would be waaaay happier with examples in tests :)
@ryantxu Please help review. Thanks. |
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.
updated
Hi @torkelo , is there any other problem in the PR or some process? We expect this RP will be merged and start use it in my dashboards. Please help review, I will fix if there is any problem. |
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.
Really sorry for slow feedback, this looks great now. Just a small detail missing in the docs
@torkelo @ryantxu @oddlittlebird Please help review, many thanks. |
LGTM! |
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.
please help review
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.
Please see my suggestions.
Hang on, going to adjust my suggestions as I hear that double quotes are allowed (I'm used to them not being allowed). |
OK, edited my suggestions :) |
Thanks @aknuds1 . Please help review again. |
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.
Thanks for applying my suggestions, I just saw a remaining typo.
Can you please merge this branch with Grafana master, in order to fix a CI failure? |
Co-Authored-By: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
Co-Authored-By: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
Co-Authored-By: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
Update Singlequote and Doublequote descriptions in templating.md
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.
LGTM
I'm just pushing a merge with latest Grafana master to your branch, in order to fix CI. Hope you don't mind :) |
Thanks very much for contributing to Grafana! |
What this PR does / why we need it:
This PR adds 3 formatting options of variables, mainly for SQL.
New formatting list:
singlequote: Quote variable value(s) with single quote, escape single quotes in original value with backslashes.
doublequote: Quote variable value(s) with double quote, escape double quotes in original value with backslashes.
sqlstring: Quote variable value(s) with single quote, escape
'
in original value by''
.When writing SQL statements, we usually need this kind of statement “select * from table1 where name in (${var})”, but Grafana doesn’t provides formatting option to quote string of SQL.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer: