Skip to content

Commit

Permalink
zeta-serve: author/committer sql fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fcharlie committed Feb 11, 2025
1 parent 8a88180 commit 04dc088
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/serve/odb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func (d *MetadataDB) EncodeCommit(ctx context.Context, cc *object.Commit) error
if err != nil {
return err
}
_, err = d.ExecContext(ctx, "insert into commits(rid, hash, author, committer, bindata, created_at, updated_at) values(?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE rid = rid",
d.rid, cc.Hash.String(), cc.Author.Email, cc.Committer.Email, bindata, cc.Author.When, cc.Committer.When)
_, err = d.ExecContext(ctx, "insert into commits(rid, hash, author, committer, bindata) values(?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE rid = rid",
d.rid, cc.Hash.String(), cc.Author.Email, cc.Committer.Email, bindata)
return err
}

Expand All @@ -59,11 +59,11 @@ func (d *MetadataDB) BatchEncodeCommit(ctx context.Context, commits []*object.Co
if err != nil {
return err
}
args = append(args, d.rid, c.Hash.String(), c.Author.Email, c.Committer.Email, bindata, c.Author.When, c.Committer.When)
args = append(args, d.rid, c.Hash.String(), c.Author.Email, c.Committer.Email, bindata)
}
sb := strings.Builder{}
sb.WriteString("insert into commits(rid, hash, author, committer, bindata, created_at, updated_at) values(?, ?, ?, ?, ?, ?, ?)")
sb.WriteString(strings.Repeat(", (?, ?, ?, ?, ?, ?, ?)", len(cs)-1))
sb.WriteString("insert into commits(rid, hash, author, committer, bindata) values(?, ?, ?, ?, ?)")
sb.WriteString(strings.Repeat(", (?, ?, ?, ?, ?)", len(cs)-1))
sb.WriteString(" ON DUPLICATE KEY UPDATE rid = rid")
_, err := d.ExecContext(ctx, sb.String(), args...)
return err
Expand Down

0 comments on commit 04dc088

Please sign in to comment.