Skip to content

Commit

Permalink
Add default status value to inserts and updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Jun 26, 2022
1 parent ff6bc0e commit f44c5c8
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions internal/data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ func (d *Data) InsertSubmissionEntry(e Entry) (int, error) {

// UpdateEntry updates a dictionary entry.
func (d *Data) UpdateEntry(id int, e Entry) error {
if e.Status == "" {
e.Status = StatusEnabled
}

_, err := d.queries.UpdateEntry.Exec(id,
e.Content,
e.Initial,
Expand Down Expand Up @@ -401,13 +405,20 @@ func (d *Data) insertEntry(e Entry, stmt *sqlx.Stmt) (int, error) {
}
}

if e.Status == "" {
e.Status = StatusEnabled
}

var id int
err := stmt.Get(&id, e.Content, e.Initial, e.Weight, tokens,
tsVectorLang, e.Lang, e.Tags, e.Phones, e.Notes, e.Status)
err := stmt.Get(&id, e.Content, e.Initial, e.Weight, tokens, tsVectorLang, e.Lang, e.Tags, e.Phones, e.Notes, e.Status)
return id, err
}

func (d *Data) insertRelation(fromID, toID int, r Relation, stmt *sqlx.Stmt) (int, error) {
if r.Status == "" {
r.Status = StatusEnabled
}

var id int
err := stmt.Get(&id, fromID, toID, r.Types, r.Tags, r.Notes, r.Weight, r.Status)
return id, err
Expand Down

0 comments on commit f44c5c8

Please sign in to comment.