Help!
I upgraded from 9.2 to 9.3 and its broken all my queries using a “constant” type variable.
Here is a simple query I run off a library panel
SELECT MAX(DATEADD(HOUR,-@OFFSET,[REPORT_DATE])) AS 'time',
SUM(QUANTITY) AS 'Pieces'
FROM
[WORKCENTER_PRODUCTIVITY]
WHERE
$__timeFilter([REPORT_DATE]) AND ($DEPARTMENT_WORKCENTERS)
GROUP BY
DATEADD(DAY,0, DATEDIFF(DAY,0, [REPORT_DATE]))
In the WHERE
section, you can see I use the variable $DEPARTMENT_WORKCENTERS
to augment my query depending on what page the panel is located on.
Here is a sample of what the $DEPARTMENT_WORKCENTERS
string would look like: [WORKCENTER]='AUTO HST-01'OR [WORKCENTER]='AUTO HST-02'OR [WORKCENTER]='AUTO HST-03'
The problem with updating to 9.3 is it has started double single-quoting my strings (the workcenter names) inside that constant.
If I go to the query inspector and inspect the query being sent to my server, all the work centers have a additional quote mark around them now, making the query break.
SELECT MAX(DATEADD(HOUR,-@OFFSET,[REPORT_DATE])) AS 'time',
SUM(QUANTITY) AS 'Pieces'
FROM
[WORKCENTER_PRODUCTIVITY]
WHERE
[REPORT_DATE] BETWEEN '2022-11-28T19:48:39Z' AND '2022-12-12T19:48:39Z' AND ([WORKCENTER]=''AUTO HST-01''OR [WORKCENTER]=''AUTO HST-02''OR [WORKCENTER]=''AUTO HST-03'')
GROUP BY
DATEADD(DAY,0, DATEDIFF(DAY,0, [REPORT_DATE]))
Any help would be greatly appreciated. Its like grafana is trying to sanitize my query for me but doing it wrong. I dunno what to do.
EDIT - RESOLVED
Based off the answer provided by aleph_0x I found the solution was to encapsulate my $DEPARTMENT_WORKCENTERS
with curly brackets and add :raw
so it becomes ${DEPARTMENT_WORKCENTERS:raw}
. Hopefully this answer is useful to someone else in the future. Thank you aleph_0x.