Skip to content

Commit

Permalink
Merge branch 'master' into bump-ui-versions
Browse files Browse the repository at this point in the history
  • Loading branch information
breezewish authored Nov 22, 2021
2 parents 0924000 + 7ce4e0e commit 6267c75
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 5 additions & 1 deletion pkg/keyvisual/storage/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"encoding/gob"
"time"

"gorm.io/gorm"

"github.com/pingcap/tidb-dashboard/pkg/dbstore"
"github.com/pingcap/tidb-dashboard/pkg/keyvisual/matrix"
)
Expand Down Expand Up @@ -66,7 +68,9 @@ func CreateTableAxisModelIfNotExists(db *dbstore.DB) (bool, error) {
}

func ClearTableAxisModel(db *dbstore.DB) error {
return db.Delete(&AxisModel{}).Error
return db.Session(&gorm.Session{AllowGlobalUpdate: true}).
Delete(&AxisModel{}).
Error
}

func FindAxisModelsOrderByTime(db *dbstore.DB, layerNum uint8) ([]*AxisModel, error) {
Expand Down
10 changes: 5 additions & 5 deletions pkg/keyvisual/storage/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (t *testDbstoreSuite) TestClearTableAxisModel(c *C) {
if err != nil {
c.Fatalf("Count table AxisModel error: %v", err)
}
c.Assert(count, Equals, 1)
c.Assert(count, Equals, int64(1))

err = ClearTableAxisModel(t.db)
c.Assert(err, IsNil)
Expand All @@ -72,7 +72,7 @@ func (t *testDbstoreSuite) TestClearTableAxisModel(c *C) {
if err != nil {
c.Fatalf("Count table AxisModel error: %v", err)
}
c.Assert(count, Equals, 0)
c.Assert(count, Equals, int64(0))
}

func (t *testDbstoreSuite) TestAxisModelFunc(c *C) {
Expand Down Expand Up @@ -112,7 +112,7 @@ func (t *testDbstoreSuite) TestAxisModelFunc(c *C) {
if err != nil {
c.Fatalf("Count table AxisModel error: %v", err)
}
c.Assert(count, Equals, 0)
c.Assert(count, Equals, int64(0))

err = axisModel.Delete(t.db)
c.Assert(err, IsNil)
Expand Down Expand Up @@ -146,7 +146,7 @@ func (t *testDbstoreSuite) TestAxisModelsFindAndDelete(c *C) {
if err != nil {
c.Fatalf("Count table AxisModel error: %v", err)
}
c.Assert(count, Equals, int(maxLayerNum)*axisModelNumEachLayer)
c.Assert(count, Equals, int64(int(maxLayerNum)*axisModelNumEachLayer))

findLayerNum := maxLayerNum - 1
axisModels, err := FindAxisModelsOrderByTime(t.db, findLayerNum)
Expand All @@ -164,7 +164,7 @@ func (t *testDbstoreSuite) TestAxisModelsFindAndDelete(c *C) {
if err != nil {
c.Fatalf("Count table AxisModel error: %v", err)
}
c.Assert(count, Equals, int(maxLayerNum-1)*axisModelNumEachLayer)
c.Assert(count, Equals, int64(int(maxLayerNum-1)*axisModelNumEachLayer))
}

func axisModelsDeepEqual(obtainedAxisModels []*AxisModel, expectedAxisModels []*AxisModel, c *C) {
Expand Down

0 comments on commit 6267c75

Please sign in to comment.