Skip to content

Commit 752b875

Browse files
authored
fix: error when firstly create chart in an app
1 parent 6cb7501 commit 752b875

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

repositories/chart.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,11 @@ func (r *chartRepository) FindByChartID(chartId string) (*models.Chart, error) {
6565

6666
func (r *chartRepository) GetMaxRowID(appId string) (int64, error) {
6767
var chart models.Chart
68-
err := r.db.Where("app_id = ?", appId).Order("row_id desc").First(&chart).Error
69-
if err != nil {
68+
result := r.db.Where("app_id = ?", appId).Order("row_id desc").First(&chart)
69+
if result.RowsAffected == 0 {
70+
return 1, nil
71+
}
72+
if err := result.Error, err != nil {
7073
return 0, err
7174
}
7275

0 commit comments

Comments
 (0)