How to remove built-in quotes from variable substitution

93 Views Asked by At

I have a custom variable tabela with values example_table, example2, example3. And second variable kolumna with values score, date, Rising. Those variables are used in repeat by variable rows and panels.

When I try to use following query with my MySQL data source I get an error.

USE server;
SELECT date, $kolumna FROM $tabela;

db query error: Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT date, 'score' FROM 'example2'' at line 2

It seems like when variable is used like this: $kolumna, it is substituted with built-in single quotes: 'score'. How can I avoid this?

1

There are 1 best solutions below

0
markalex On

As official documentation states:

From Grafana 4.7.0, template variable values are only quoted when the template variable is a multi-value.

And since your variables are multi-value (since they are used for repeat), you got built-in quoting.

Disabling of built-in quoting described here:

To disable quoting, use the csv formatting option for variables:

${servers:csv}

Additionally, since here on the moment of substitution variable is effectively guaranteed to have a single value, you can use ${variable:raw}.