Skip to content

Commit

Permalink
Merge pull request #246 from systemli/Update-Ticker-Associations-on-Save
Browse files Browse the repository at this point in the history
🗃️ Update Ticker Associations on Save
  • Loading branch information
0x46616c6b authored Oct 20, 2023
2 parents e01a926 + 344e997 commit 4bf7a2e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/storage/sql_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ func (s *SqlStorage) FindTickerByID(id int) (Ticker, error) {
}

func (s *SqlStorage) SaveTicker(ticker *Ticker) error {
return s.db.Save(ticker).Error
if ticker.ID == 0 {
return s.db.Create(ticker).Error
}

return s.db.Session(&gorm.Session{FullSaveAssociations: true}).Updates(ticker).Error
}

func (s *SqlStorage) DeleteTicker(ticker Ticker) error {
Expand Down

0 comments on commit 4bf7a2e

Please sign in to comment.