mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
indent generated SQL
This commit is contained in:
parent
a24a6624e3
commit
bf21f1bf76
@ -204,14 +204,14 @@ export default class PostgresQuery {
|
|||||||
query = target.timeColumn + ' AS "time"';
|
query = target.timeColumn + ' AS "time"';
|
||||||
}
|
}
|
||||||
|
|
||||||
return query;
|
return '\n ' + query;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildMetricColumn(target) {
|
buildMetricColumn(target) {
|
||||||
let query = '';
|
let query = '';
|
||||||
|
|
||||||
if (this.target.metricColumn !== 'None') {
|
if (this.target.metricColumn !== 'None') {
|
||||||
query += ',' + this.target.metricColumn + ' AS metric';
|
query += ',\n ' + this.target.metricColumn + ' AS metric';
|
||||||
}
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
@ -220,7 +220,7 @@ export default class PostgresQuery {
|
|||||||
buildValueColumns(target) {
|
buildValueColumns(target) {
|
||||||
let query = '';
|
let query = '';
|
||||||
for (let i = 0; i < target.select.length; i++) {
|
for (let i = 0; i < target.select.length; i++) {
|
||||||
query += ', ' + this.buildValueColumn(target, target.select[i]);
|
query += ',\n ' + this.buildValueColumn(target, target.select[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
@ -279,7 +279,7 @@ export default class PostgresQuery {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (conditions.length > 0) {
|
if (conditions.length > 0) {
|
||||||
query = ' WHERE ' + conditions.join(' AND ');
|
query = '\nWHERE\n ' + conditions.join(' AND\n ');
|
||||||
}
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
@ -302,7 +302,7 @@ export default class PostgresQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (groupBySection.length) {
|
if (groupBySection.length) {
|
||||||
query = ' GROUP BY ' + groupBySection;
|
query = '\nGROUP BY ' + groupBySection;
|
||||||
if (this.target.metricColumn !== 'None') {
|
if (this.target.metricColumn !== 'None') {
|
||||||
query += ',2';
|
query += ',2';
|
||||||
}
|
}
|
||||||
@ -317,12 +317,12 @@ export default class PostgresQuery {
|
|||||||
query += this.buildMetricColumn(target);
|
query += this.buildMetricColumn(target);
|
||||||
query += this.buildValueColumns(target);
|
query += this.buildValueColumns(target);
|
||||||
|
|
||||||
query += ' FROM ' + target.schema + '.' + target.table;
|
query += '\nFROM ' + target.schema + '.' + target.table;
|
||||||
|
|
||||||
query += this.buildWhereClause(target);
|
query += this.buildWhereClause(target);
|
||||||
query += this.buildGroupByClause(target);
|
query += this.buildGroupByClause(target);
|
||||||
|
|
||||||
query += ' ORDER BY 1';
|
query += '\nORDER BY 1';
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user