Skip to content

Commit 0df4c9f

Browse files
committed
fix: Add getColumnsFromQuery quote stripping
[big] The dataframe parser would fail to assign fields wrapped in quotes i.e. select 1 as "server"
1 parent 31a8d33 commit 0df4c9f

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/features/log/queryResponseBuilder.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@ export const getGraphDataFrame = (data: any, target: MyQuery, app: string) => {
5151

5252
for (let i = 0; i < fields.length; i++) {
5353
if (fields[i] === '_timestamp') {
54-
graphData.addField({
55-
config: {
56-
filterable: true,
57-
},
58-
name: 'Time',
59-
type: FieldType.time,
60-
});
54+
graphData.addField({
55+
config: {
56+
filterable: true,
57+
},
58+
name: 'Time',
59+
type: FieldType.time,
60+
});
6161
} else {
62-
graphData.addField({
63-
name: fields[i],
64-
});
62+
graphData.addField({
63+
name: fields[i],
64+
});
6565
}
6666
}
6767

@@ -140,7 +140,9 @@ const getColumnsFromQuery = (query: string) => {
140140

141141
// If alias exists, use that, otherwise use column name
142142
if (aliasMatch) {
143-
columnNames.push(aliasMatch[1]);
143+
// SQL alias may have quotes, strip those.
144+
let stripped = aliasMatch[1].replace(/^['"]|['"]$/g, '');
145+
columnNames.push(stripped);
144146
} else {
145147
columnNames.push(column);
146148
}

0 commit comments

Comments
 (0)