mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
unify quoting
This commit is contained in:
@@ -7,6 +7,7 @@ export class PostgresDatasource {
|
|||||||
name: any;
|
name: any;
|
||||||
jsonData: any;
|
jsonData: any;
|
||||||
responseParser: ResponseParser;
|
responseParser: ResponseParser;
|
||||||
|
queryModel: PostgresQuery;
|
||||||
|
|
||||||
/** @ngInject **/
|
/** @ngInject **/
|
||||||
constructor(instanceSettings, private backendSrv, private $q, private templateSrv, private timeSrv) {
|
constructor(instanceSettings, private backendSrv, private $q, private templateSrv, private timeSrv) {
|
||||||
@@ -14,12 +15,13 @@ export class PostgresDatasource {
|
|||||||
this.id = instanceSettings.id;
|
this.id = instanceSettings.id;
|
||||||
this.jsonData = instanceSettings.jsonData;
|
this.jsonData = instanceSettings.jsonData;
|
||||||
this.responseParser = new ResponseParser(this.$q);
|
this.responseParser = new ResponseParser(this.$q);
|
||||||
|
this.queryModel = new PostgresQuery({});
|
||||||
}
|
}
|
||||||
|
|
||||||
interpolateVariable(value, variable) {
|
interpolateVariable(value, variable) {
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
if (variable.multi || variable.includeAll) {
|
if (variable.multi || variable.includeAll) {
|
||||||
return "'" + value.replace(/'/g, `''`) + "'";
|
return this.queryModel.quoteLiteral(value);
|
||||||
} else {
|
} else {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@@ -29,8 +31,8 @@ export class PostgresDatasource {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
let quotedValues = _.map(value, function(val) {
|
let quotedValues = _.map(value, v => {
|
||||||
return "'" + val.replace(/'/g, `''`) + "'";
|
return this.queryModel.quoteLiteral(v);
|
||||||
});
|
});
|
||||||
return quotedValues.join(',');
|
return quotedValues.join(',');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user