Skip to content

Commit 136bdb9

Browse files
paragornineinchnick
authored andcommitted
fix variables interpolations
Previously, applyTemplateVariables directly modified the query object by assigning to query.rawSQL, causing unintended side effects due to object mutation. This update returns a new object instead, preserving immutability.
1 parent 345d677 commit 136bdb9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/datasource.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ export class DataSource extends DataSourceWithBackend<TrinoQuery, TrinoDataSourc
5050
);
5151
}
5252

53-
applyTemplateVariables(query: TrinoQuery, scopedVars: ScopedVars): Record<string, any> {
54-
query.rawSQL = getTemplateSrv().replace(query.rawSQL, scopedVars, this.interpolateQueryStr);
55-
return query;
53+
applyTemplateVariables(query: TrinoQuery, scopedVars: ScopedVars) {
54+
return {
55+
...query,
56+
rawSQL: getTemplateSrv().replace(query.rawSQL, scopedVars, this.interpolateQueryStr),
57+
};
5658
}
5759

5860
interpolateQueryStr(value: any, variable: { multi: any; includeAll: any }, defaultFormatFn: any) {

0 commit comments

Comments
 (0)