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
bb7e5838
Commit
bb7e5838
authored
Aug 01, 2018
by
Brice Maron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix custom variable quoting in sql* query interpolations
parent
9d374377
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
6 deletions
+27
-6
public/app/plugins/datasource/mssql/datasource.ts
+2
-2
public/app/plugins/datasource/mssql/specs/datasource.jest.ts
+7
-0
public/app/plugins/datasource/mysql/datasource.ts
+2
-2
public/app/plugins/datasource/mysql/specs/datasource.jest.ts
+7
-0
public/app/plugins/datasource/postgres/datasource.ts
+2
-2
public/app/plugins/datasource/postgres/specs/datasource.jest.ts
+7
-0
No files found.
public/app/plugins/datasource/mssql/datasource.ts
View file @
bb7e5838
...
@@ -16,7 +16,7 @@ export class MssqlDatasource {
...
@@ -16,7 +16,7 @@ export class MssqlDatasource {
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
+
"'"
;
return
"'"
+
value
.
replace
(
/'/g
,
`''`
)
+
"'"
;
}
else
{
}
else
{
return
value
;
return
value
;
}
}
...
@@ -31,7 +31,7 @@ export class MssqlDatasource {
...
@@ -31,7 +31,7 @@ export class MssqlDatasource {
return
value
;
return
value
;
}
}
return
"'"
+
val
+
"'"
;
return
"'"
+
val
.
replace
(
/'/g
,
`''`
)
+
"'"
;
});
});
return
quotedValues
.
join
(
','
);
return
quotedValues
.
join
(
','
);
}
}
...
...
public/app/plugins/datasource/mssql/specs/datasource.jest.ts
View file @
bb7e5838
...
@@ -218,6 +218,13 @@ describe('MSSQLDatasource', function() {
...
@@ -218,6 +218,13 @@ describe('MSSQLDatasource', 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 value is a string'
,
()
=>
{
describe
(
'and variable allows all and value is a string'
,
()
=>
{
it
(
'should return a quoted value'
,
()
=>
{
it
(
'should return a quoted value'
,
()
=>
{
ctx
.
variable
.
includeAll
=
true
;
ctx
.
variable
.
includeAll
=
true
;
...
...
public/app/plugins/datasource/mysql/datasource.ts
View file @
bb7e5838
...
@@ -16,7 +16,7 @@ export class MysqlDatasource {
...
@@ -16,7 +16,7 @@ export class MysqlDatasource {
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
+
"'"
;
return
"'"
+
value
.
replace
(
/'/g
,
`''`
)
+
"'"
;
}
else
{
}
else
{
return
value
;
return
value
;
}
}
...
@@ -31,7 +31,7 @@ export class MysqlDatasource {
...
@@ -31,7 +31,7 @@ export class MysqlDatasource {
return
value
;
return
value
;
}
}
return
"'"
+
val
+
"'"
;
return
"'"
+
val
.
replace
(
/'/g
,
`''`
)
+
"'"
;
});
});
return
quotedValues
.
join
(
','
);
return
quotedValues
.
join
(
','
);
}
}
...
...
public/app/plugins/datasource/mysql/specs/datasource.jest.ts
View file @
bb7e5838
...
@@ -214,6 +214,13 @@ describe('MySQLDatasource', function() {
...
@@ -214,6 +214,13 @@ describe('MySQLDatasource', 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 value is a string'
,
()
=>
{
describe
(
'and variable allows all and value is a string'
,
()
=>
{
it
(
'should return a quoted value'
,
()
=>
{
it
(
'should return a quoted value'
,
()
=>
{
ctx
.
variable
.
includeAll
=
true
;
ctx
.
variable
.
includeAll
=
true
;
...
...
public/app/plugins/datasource/postgres/datasource.ts
View file @
bb7e5838
...
@@ -16,7 +16,7 @@ export class PostgresDatasource {
...
@@ -16,7 +16,7 @@ export class PostgresDatasource {
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
+
"'"
;
return
"'"
+
value
.
replace
(
/'/g
,
`''`
)
+
"'"
;
}
else
{
}
else
{
return
value
;
return
value
;
}
}
...
@@ -27,7 +27,7 @@ export class PostgresDatasource {
...
@@ -27,7 +27,7 @@ export class PostgresDatasource {
}
}
var
quotedValues
=
_
.
map
(
value
,
function
(
val
)
{
var
quotedValues
=
_
.
map
(
value
,
function
(
val
)
{
return
"'"
+
val
+
"'"
;
return
"'"
+
val
.
replace
(
/'/g
,
`''`
)
+
"'"
;
});
});
return
quotedValues
.
join
(
','
);
return
quotedValues
.
join
(
','
);
}
}
...
...
public/app/plugins/datasource/postgres/specs/datasource.jest.ts
View file @
bb7e5838
...
@@ -215,6 +215,13 @@ describe('PostgreSQLDatasource', function() {
...
@@ -215,6 +215,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'
,
()
=>
{
describe
(
'and variable allows all and is a string'
,
()
=>
{
it
(
'should return a quoted value'
,
()
=>
{
it
(
'should return a quoted value'
,
()
=>
{
ctx
.
variable
.
includeAll
=
true
;
ctx
.
variable
.
includeAll
=
true
;
...
...
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