Skip to content

Commit

Permalink
fix: create index failed when table name has -. (#793) (#795)
Browse files Browse the repository at this point in the history
Co-authored-by: OpenIM-Gordon <46924906+FGadvancer@users.noreply.github.com>
  • Loading branch information
OpenIM-Robot and FGadvancer authored Nov 27, 2024
1 parent 4a45fdf commit 61d6b6e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/db/chat_log_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ func (d *DataBase) initChatLog(ctx context.Context, conversationID string) error
if result := d.conn.Exec(createTableSQL); result.Error != nil {
return errs.WrapMsg(result.Error, "Create table failed", "table", tableName)
}
result := d.conn.Exec(fmt.Sprintf("CREATE INDEX %s ON %s (seq)", "index_seq_"+conversationID, tableName))
result := d.conn.Exec(fmt.Sprintf("CREATE INDEX `%s` ON %s (seq)", "index_seq_"+conversationID, tableName))
if result.Error != nil {
return errs.WrapMsg(result.Error, "Create index_seq failed", "table", tableName, "index", "index_seq_"+conversationID)
}
result = d.conn.Exec(fmt.Sprintf("CREATE INDEX %s ON %s (send_time)", "index_send_time_"+conversationID, tableName))
result = d.conn.Exec(fmt.Sprintf("CREATE INDEX `%s` ON %s (send_time)", "index_send_time_"+conversationID, tableName))
if result.Error != nil {
return errs.WrapMsg(result.Error, "Create index_send_time failed", "table", tableName, "index", "index_send_time_"+conversationID)
}
Expand Down

0 comments on commit 61d6b6e

Please sign in to comment.