Bladeren bron

fix bug in query generation with metricColumn

Sven Klemm 7 jaren geleden
bovenliggende
commit
d9648f1fe7

+ 1 - 1
public/app/plugins/datasource/postgres/postgres_query.ts

@@ -220,7 +220,7 @@ export default class PostgresQuery {
 
     query += '\n  ' + this.buildTimeColumn();
     if (this.hasMetricColumn()) {
-      query += '\n  ' + this.buildMetricColumn();
+      query += ',\n  ' + this.buildMetricColumn();
     }
     query += this.buildValueColumns();
 

+ 4 - 0
public/app/plugins/datasource/postgres/specs/postgres_query.jest.ts

@@ -103,5 +103,9 @@ describe('PostgresQuery', function() {
     let query = new PostgresQuery(target, templateSrv);
 
     expect(query.buildQuery()).toBe(result);
+
+    query.target.metricColumn = 'm';
+    result = 'SELECT\n  t AS "time",\n  m AS metric,\n  value\nFROM public.table\nORDER BY 1';
+    expect(query.buildQuery()).toBe(result);
   });
 });