Skip to content
This repository has been archived by the owner on Apr 12, 2019. It is now read-only.

Quotes Around Variable in WHERE Clause #50

Open
davidraker opened this issue Apr 9, 2018 · 3 comments
Open

Quotes Around Variable in WHERE Clause #50

davidraker opened this issue Apr 9, 2018 · 3 comments

Comments

@davidraker
Copy link

Attempting to use a variable in the WHERE clause as:
WHERE column_name = $variable/string
or
WHERE column_name = [[variable]]/string
For variable contents: "foo" this should expand to 'foo/string'.
Instead it expands to 'foo'/string.
Similar behavior seems to have been discussed for the MySQL and PostgreSQL (grafana/grafana#9611) but this still seems to be a problem for the Crate datasource.

@davidraker
Copy link
Author

On further investigation, I did find that this works as a workaround:
WHERE column_name = $variable || '/string'
This seems to be contrary to the Grafana documentation on how this should work, however.

@agaldemas
Copy link

Hello,
I had the same sort of issue trying to use a variable in a WHERE clause in the metrics interface
WHERE column_name like $variable
or
WHERE column_name like [[variable]]
is translated in the query as :
WHERE column_name like ''<variable value>'' the 2 single quotes surround,
results in an sql error...

I manage to workaround the problem by adding '' || before $variable to have:
WHERE column_name like
'' || $variable
in the metrics interface avoid the issue in the query:
SELECT ... WHERE ... AND column_name like '' || '<variable value>' GROUP...
which success and behave as wanted too ;O)

Hope it will help, before the issue can be fixed.

@scjimenez
Copy link

Hi hi :)

Thanks a lot for your input! With our latest effort, the PostgreSQL implementation of Grafana works fine with CrateDB. Hence, we skip the Grafana Datasource Plugin for CrateDB and move over to the PostgreSQL data source. In case you wanna read more about how to pair CrateDB and Grafana, please take a look at this blog post of ours.

Best, Stephanie

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants