Skip to content

Commit 4735304

Browse files
author
Roman M
committed
add additional check for variable datasource name
1 parent 37e58c6 commit 4735304

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

docker/grafana/dashboards/replacement_adhoc.json

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"editable": true,
1919
"fiscalYearStartMonth": 0,
2020
"graphTooltip": 0,
21-
"id": 20,
21+
"id": 48,
2222
"links": [],
2323
"panels": [
2424
{
@@ -91,7 +91,7 @@
9191
"adHocValuesQuery": "",
9292
"add_metadata": true,
9393
"contextWindowSize": "10",
94-
"database": "system",
94+
"database": "default",
9595
"datasource": {
9696
"type": "vertamedia-clickhouse-datasource",
9797
"uid": "clickhouse"
@@ -107,16 +107,16 @@
107107
"intervalFactor": 1,
108108
"nullifySparse": false,
109109
"query": "SELECT * FROM $table WHERE $timeFilter AND $adhoc",
110-
"rawQuery": "/* grafana dashboard='Plugin test adhoc replacement', user=0 */\nSELECT * FROM system.query_log WHERE event_date >= toDate(1756117558) AND event_date <= toDate(1756139158) AND event_time >= toDateTime(1756117558) AND event_time <= toDateTime(1756139158) AND 1",
110+
"rawQuery": "/* grafana dashboard='Plugin test adhoc replacement #804', user=0 */\nSELECT * FROM default.oses WHERE event_date >= toDate(1756492197) AND event_date <= toDate(1756513797) AND event_time >= toDateTime(1756492197) AND event_time <= toDateTime(1756513797) AND (OS = 'os1')",
111111
"refId": "A",
112112
"round": "0s",
113113
"showFormattedSQL": true,
114114
"skip_comments": true,
115-
"table": "query_log",
115+
"table": "oses",
116116
"useWindowFuncForMacros": true
117117
}
118118
],
119-
"title": "New panel",
119+
"title": "Datasource with 2 adhoc variables, one imported and another one added manually with correct UID",
120120
"type": "table"
121121
}
122122
],
@@ -145,6 +145,26 @@
145145
],
146146
"name": "query0",
147147
"type": "adhoc"
148+
},
149+
{
150+
"datasource": {
151+
"type": "vertamedia-clickhouse-datasource",
152+
"uid": "P7E099F39B84EA795"
153+
},
154+
"filters": [
155+
{
156+
"condition": "",
157+
"key": "default.oses.OS",
158+
"keyLabel": "default.oses.OS",
159+
"operator": "=",
160+
"value": "os1",
161+
"valueLabels": [
162+
"os1"
163+
]
164+
}
165+
],
166+
"name": "query1",
167+
"type": "adhoc"
148168
}
149169
]
150170
},

src/views/QueryEditor/helpers/getAdHocFilters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const getAdhocFilters = (datasourceName, datasourceUid: any) => {
2828
}
2929

3030
// Now compare resolved UIDs
31-
if (variableUid === datasourceUid) {
31+
if (variableUid === datasourceUid || variableUid === datasourceName) {
3232
filters = filters.concat(variable.filters);
3333
}
3434
}

0 commit comments

Comments
 (0)