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
d49f0bed
Commit
d49f0bed
authored
Mar 02, 2019
by
Marcus Efraimsson
Committed by
Carl Bergquist
Mar 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: prevent datasource json data stored as nil (#15508)
prevent datasource json data stored as nil closes #14239
parent
06de01dc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
pkg/services/sqlstore/datasource.go
+10
-0
pkg/services/sqlstore/migrations/datasource_mig.go
+3
-0
No files found.
pkg/services/sqlstore/datasource.go
View file @
d49f0bed
...
...
@@ -3,6 +3,8 @@ package sqlstore
import
(
"time"
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/go-xorm/xorm"
"github.com/grafana/grafana/pkg/bus"
...
...
@@ -95,6 +97,10 @@ func AddDataSource(cmd *m.AddDataSourceCommand) error {
return
m
.
ErrDataSourceNameExists
}
if
cmd
.
JsonData
==
nil
{
cmd
.
JsonData
=
simplejson
.
New
()
}
ds
:=
&
m
.
DataSource
{
OrgId
:
cmd
.
OrgId
,
Name
:
cmd
.
Name
,
...
...
@@ -142,6 +148,10 @@ func updateIsDefaultFlag(ds *m.DataSource, sess *DBSession) error {
func
UpdateDataSource
(
cmd
*
m
.
UpdateDataSourceCommand
)
error
{
return
inTransaction
(
func
(
sess
*
DBSession
)
error
{
if
cmd
.
JsonData
==
nil
{
cmd
.
JsonData
=
simplejson
.
New
()
}
ds
:=
&
m
.
DataSource
{
Id
:
cmd
.
Id
,
OrgId
:
cmd
.
OrgId
,
...
...
pkg/services/sqlstore/migrations/datasource_mig.go
View file @
d49f0bed
...
...
@@ -130,4 +130,7 @@ func addDataSourceMigration(mg *Migrator) {
const
migrateLoggingToLoki
=
`UPDATE data_source SET type = 'loki' WHERE type = 'logging'`
mg
.
AddMigration
(
"Migrate logging ds to loki ds"
,
NewRawSqlMigration
(
migrateLoggingToLoki
))
const
setEmptyJSONWhereNullJSON
=
`UPDATE data_source SET json_data = '{}' WHERE json_data is null`
mg
.
AddMigration
(
"Update json_data with nulls"
,
NewRawSqlMigration
(
setEmptyJSONWhereNullJSON
))
}
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