grafana / sqlds

A package that assists writing SQL-driven datasources
Apache License 2.0
18 stars 12 forks source link

calling same macro with different parameters doesn't work #11

Closed yesoreyeram closed 3 years ago

yesoreyeram commented 3 years ago

In SQL Query when the same macro used multiple times with different parameters, they are not parsed correctly.

WHERE $__timeFilter("c_timestamp") AND $__fromTimeFilter("c_string",YYYY-MM-DD) -- works
---
WHERE $__timeFilter("c_timestamp") AND $__fromTimeFilter("c_timestamp") -- works
---
WHERE $__timeFilter("c_timestamp")  AND $__fromTimeFilter("c_timestamp")  AND $__fromTimeFilter("c_timestamp") -- works
---
WHERE $__timeFilter("c_timestamp") AND $__fromTimeFilter("c_string",YYYY-MM-DD)  AND $__fromTimeFilter("c_timestamp") - doesn't work

in the above example, last one tranlsated as follows

WHERE "c_timestamp" > '2019-04-29T12:47:46Z' AND "c_timestamp" < '2022-04-29T12:47:46Z' AND TO_TIMESTAMP("c_string",'YYYY-MM-DD') > '2019-04-29T12:47:46Z'  AND $__fromTimeFilter("c_timestamp") -- doesn't work