fr-ser / grafana-sqlite-datasource

Grafana Plugin to enable SQLite as a Datasource
Apache License 2.0
124 stars 17 forks source link

All-filter not producing expected query, query returns 0 results #82

Closed redturtlepower closed 2 years ago

redturtlepower commented 2 years ago

Describe the bug Using multi-value filters produces query that is not understood by SQLite and retunrs no results: Generated filter query is like column="{value1, value2}" but shouldn't it be like column IN ("value1", "value2")?

To Reproduce Steps to reproduce the behavior:

  1. Use sqlite database from plugin
  2. Create a multi-value filter and select "All"

Versions (please complete the following information):

fr-ser commented 2 years ago

Could you export your dashboard (including settings for variables) as a JSON file and attach it here?

In my example query I use it works fine (by selecting all of them individually and with the "all" option)

fr-ser commented 2 years ago

Maybe as a reference:

I have the following query running fine:

with data(time, temperature, city) AS (VALUES
(724125600, 10, 'London'), (724161600, 11, 'London'),
(724161600, 20, 'New York'), (724197600, 21, 'New York'),
(724125600, 25, 'Washington'), (724197600, 26, 'Washington')
) SELECT * from data
WHERE city in (${cities:singlequote})
order by time

With this being the query variable

SELECT * FROM (VALUES ('London'), ('New York'), ('Washington'))
redturtlepower commented 2 years ago

Thanks for the example. This is no bug, the query was wrong on my side. I was not aware of the :singlequote command. Also I had a = instead of IN in my query.