Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
caa8b610
Commit
caa8b610
authored
Oct 31, 2017
by
Sven Klemm
Committed by
Torkel Ödegaard
Oct 31, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
always quote template variables for postgres when multi-value or include (#9714)
all is allowed
parent
ae11bf7c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
5 deletions
+29
-5
public/app/plugins/datasource/postgres/datasource.ts
+6
-2
public/app/plugins/datasource/postgres/specs/datasource_specs.ts
+23
-3
No files found.
public/app/plugins/datasource/postgres/datasource.ts
View file @
caa8b610
...
...
@@ -15,9 +15,13 @@ export class PostgresDatasource {
this
.
responseParser
=
new
ResponseParser
(
this
.
$q
);
}
interpolateVariable
(
value
)
{
interpolateVariable
(
value
,
variable
)
{
if
(
typeof
value
===
'string'
)
{
return
value
;
if
(
variable
.
multi
||
variable
.
includeAll
)
{
return
'
\'
'
+
value
+
'
\'
'
;
}
else
{
return
value
;
}
}
if
(
typeof
value
===
'number'
)
{
...
...
public/app/plugins/datasource/postgres/specs/datasource_specs.ts
View file @
caa8b610
...
...
@@ -2,6 +2,7 @@ import {describe, beforeEach, it, expect, angularMocks} from 'test/lib/common';
import
moment
from
'moment'
;
import
helpers
from
'test/specs/helpers'
;
import
{
PostgresDatasource
}
from
'../datasource'
;
import
{
CustomVariable
}
from
'app/features/templating/custom_variable'
;
describe
(
'PostgreSQLDatasource'
,
function
()
{
var
ctx
=
new
helpers
.
ServiceTestContext
();
...
...
@@ -195,22 +196,41 @@ describe('PostgreSQLDatasource', function() {
});
describe
(
'When interpolating variables'
,
()
=>
{
beforeEach
(
function
()
{
ctx
.
variable
=
new
CustomVariable
({},{});
});
describe
(
'and value is a string'
,
()
=>
{
it
(
'should return an unquoted value'
,
()
=>
{
expect
(
ctx
.
ds
.
interpolateVariable
(
'abc'
)).
to
.
eql
(
'abc'
);
expect
(
ctx
.
ds
.
interpolateVariable
(
'abc'
,
ctx
.
variable
)).
to
.
eql
(
'abc'
);
});
});
describe
(
'and value is a number'
,
()
=>
{
it
(
'should return an unquoted value'
,
()
=>
{
expect
(
ctx
.
ds
.
interpolateVariable
(
1000
)).
to
.
eql
(
1000
);
expect
(
ctx
.
ds
.
interpolateVariable
(
1000
,
ctx
.
variable
)).
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
\'
'
);
expect
(
ctx
.
ds
.
interpolateVariable
([
'a'
,
'b'
,
'c'
],
ctx
.
variable
)).
to
.
eql
(
'
\'
a
\'
,
\'
b
\'
,
\'
c
\'
'
);
});
});
describe
(
'and variable allows multi-value and is a string'
,
()
=>
{
it
(
'should return a quoted value'
,
()
=>
{
ctx
.
variable
.
multi
=
true
;
expect
(
ctx
.
ds
.
interpolateVariable
(
'abc'
,
ctx
.
variable
)).
to
.
eql
(
'
\'
abc
\'
'
);
});
});
describe
(
'and variable allows all and is a string'
,
()
=>
{
it
(
'should return a quoted value'
,
()
=>
{
ctx
.
variable
.
includeAll
=
true
;
expect
(
ctx
.
ds
.
interpolateVariable
(
'abc'
,
ctx
.
variable
)).
to
.
eql
(
'
\'
abc
\'
'
);
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment