mirror of
https://github.com/grafana/grafana.git
synced 2025-09-25 11:54:20 +08:00
Merge remote-tracking branch 'upstream/master' into postgres-query-builder
This commit is contained in:
@ -17,7 +17,7 @@ export class PostgresDatasource {
|
||||
interpolateVariable(value, variable) {
|
||||
if (typeof value === 'string') {
|
||||
if (variable.multi || variable.includeAll) {
|
||||
return "'" + value + "'";
|
||||
return "'" + value.replace(/'/g, `''`) + "'";
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
@ -28,7 +28,7 @@ export class PostgresDatasource {
|
||||
}
|
||||
|
||||
let quotedValues = _.map(value, function(val) {
|
||||
return "'" + val + "'";
|
||||
return "'" + val.replace(/'/g, `''`) + "'";
|
||||
});
|
||||
return quotedValues.join(',');
|
||||
}
|
||||
|
@ -151,7 +151,8 @@ Macros:
|
||||
- $__timeEpoch -> extract(epoch from column) as "time"
|
||||
- $__timeFilter(column) -> column BETWEEN '2017-04-21T05:01:17Z' AND '2017-04-21T05:01:17Z'
|
||||
- $__unixEpochFilter(column) -> column >= 1492750877 AND column <= 1492750877
|
||||
- $__timeGroup(column,'5m') -> (extract(epoch from column)/300)::bigint*300 AS time
|
||||
- $__timeGroup(column,'5m') -> (extract(epoch from column)/300)::bigint*300
|
||||
- $__timeGroupAlias(column,'5m') -> (extract(epoch from column)/300)::bigint*300 AS "time"
|
||||
|
||||
Example of group by and order by with $__timeGroup:
|
||||
SELECT
|
||||
|
@ -226,6 +226,13 @@ describe('PostgreSQLDatasource', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('and variable contains single quote', () => {
|
||||
it('should return a quoted value', () => {
|
||||
ctx.variable.multi = true;
|
||||
expect(ctx.ds.interpolateVariable("a'bc", ctx.variable)).toEqual("'a''bc'");
|
||||
});
|
||||
});
|
||||
|
||||
describe('and variable allows all and is a string', () => {
|
||||
it('should return a quoted value', () => {
|
||||
ctx.variable.includeAll = true;
|
||||
|
Reference in New Issue
Block a user