mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Comments: fix wrong SQL query generated if Settings are not empty (#47552)
This commit is contained in:
@@ -35,12 +35,11 @@ func (s *sqlStorage) Create(ctx context.Context, orgID int64, objectType string,
|
|||||||
var result *commentmodel.Comment
|
var result *commentmodel.Comment
|
||||||
|
|
||||||
return result, s.sql.WithTransactionalDbSession(ctx, func(dbSession *sqlstore.DBSession) error {
|
return result, s.sql.WithTransactionalDbSession(ctx, func(dbSession *sqlstore.DBSession) error {
|
||||||
group := commentmodel.CommentGroup{
|
var group commentmodel.CommentGroup
|
||||||
OrgId: orgID,
|
has, err := dbSession.NoAutoCondition().Where(
|
||||||
ObjectType: objectType,
|
"org_id=? AND object_type=? AND object_id=?",
|
||||||
ObjectId: objectID,
|
orgID, objectType, objectID,
|
||||||
}
|
).Get(&group)
|
||||||
has, err := dbSession.Get(&group)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -49,6 +48,9 @@ func (s *sqlStorage) Create(ctx context.Context, orgID int64, objectType string,
|
|||||||
|
|
||||||
groupID := group.Id
|
groupID := group.Id
|
||||||
if !has {
|
if !has {
|
||||||
|
group.OrgId = orgID
|
||||||
|
group.ObjectType = objectType
|
||||||
|
group.ObjectId = objectID
|
||||||
group.Created = nowUnix
|
group.Created = nowUnix
|
||||||
group.Updated = nowUnix
|
group.Updated = nowUnix
|
||||||
group.Settings = commentmodel.Settings{}
|
group.Settings = commentmodel.Settings{}
|
||||||
@@ -95,12 +97,11 @@ func (s *sqlStorage) Get(ctx context.Context, orgID int64, objectType string, ob
|
|||||||
}
|
}
|
||||||
|
|
||||||
return result, s.sql.WithTransactionalDbSession(ctx, func(dbSession *sqlstore.DBSession) error {
|
return result, s.sql.WithTransactionalDbSession(ctx, func(dbSession *sqlstore.DBSession) error {
|
||||||
group := commentmodel.CommentGroup{
|
var group commentmodel.CommentGroup
|
||||||
OrgId: orgID,
|
has, err := dbSession.NoAutoCondition().Where(
|
||||||
ObjectType: objectType,
|
"org_id=? AND object_type=? AND object_id=?",
|
||||||
ObjectId: objectID,
|
orgID, objectType, objectID,
|
||||||
}
|
).Get(&group)
|
||||||
has, err := dbSession.Get(&group)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user