Skip to content

Commit 5e007ce

Browse files
author
Roman M
committed
add variables replacement before macros replacement
1 parent 87a2a3c commit 5e007ce

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pkg/eval/eval_query.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ func (q *EvalQuery) escapeIdentifier(identifier string) string {
291291
}
292292

293293
func (q *EvalQuery) escapeTableIdentifier(identifier string) string {
294-
if regexp.MustCompile(`^[a-zA-Z][0-9a-zA-Z_]+$`).MatchString(identifier) {
294+
if regexp.MustCompile(`^[$a-zA-Z][0-9a-zA-Z_]+$`).MatchString(identifier) {
295295
return identifier
296296
} else {
297297
return "`" + strings.Replace(identifier, "`", "\\`", -1) + "`"

src/datasource/datasource.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,13 @@ export class CHDataSource
803803
},
804804
};
805805

806+
// Apply template variable replacements (these don't require backend processing)
807+
queryData.query = this.templateSrv.replace(
808+
conditionalTest(queryData.query, this.templateSrv),
809+
options.scopedVars,
810+
createContextAwareInterpolation(queryData.query, this.templateSrv.getVariables())
811+
);
812+
806813
// SAFE OPTIMIZATION: Batch createQuery + applyAdhocFilters (reduces 3->2 calls)
807814
const queryResult = await this.resourceClient.createQueryWithAdhoc(queryData, adhocFilters);
808815

0 commit comments

Comments
 (0)