mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 17:43:35 -06:00
mysql: fix interpolation for numbers in temp vars
This commit is contained in:
parent
68829a821e
commit
002b4d3403
@ -20,7 +20,15 @@ export class MysqlDatasource {
|
||||
return '\'' + value + '\'';
|
||||
}
|
||||
|
||||
if (typeof value === 'number') {
|
||||
return value;
|
||||
}
|
||||
|
||||
var quotedValues = _.map(value, function(val) {
|
||||
if (typeof value === 'number') {
|
||||
return value;
|
||||
}
|
||||
|
||||
return '\'' + val + '\'';
|
||||
});
|
||||
return quotedValues.join(',');
|
||||
|
@ -193,4 +193,24 @@ describe('MySQLDatasource', function() {
|
||||
expect(results[0].value).to.be('same');
|
||||
});
|
||||
});
|
||||
|
||||
describe('When interpolating variables', () => {
|
||||
describe('and value is a string', () => {
|
||||
it('should return a quoted value', () => {
|
||||
expect(ctx.ds.interpolateVariable('abc')).to.eql('\'abc\'');
|
||||
});
|
||||
});
|
||||
|
||||
describe('and value is a number', () => {
|
||||
it('should return an unquoted value', () => {
|
||||
expect(ctx.ds.interpolateVariable(1000)).to.eql(1000);
|
||||
});
|
||||
});
|
||||
|
||||
describe('and value is an array of strings', () => {
|
||||
it('should return comma separated quoted values', () => {
|
||||
expect(ctx.ds.interpolateVariable(['a', 'b', 'c'])).to.eql('\'a\',\'b\',\'c\'');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user