robocanic commented on code in PR #1422:
URL: https://github.com/apache/dubbo-admin/pull/1422#discussion_r3001178671
##########
pkg/store/dbcommon/gorm_store.go:
##########
@@ -550,35 +637,76 @@ func (gs *GormStore) getKeysByIndexes(indexes
map[string]string) ([]string, erro
return result, nil
}
-// clearIndices clears all in-memory indices
-func (gs *GormStore) clearIndices() {
- gs.indices.Clear()
+// persistIndexEntries writes index entries for a resource to the database
+// If oldResource is not nil, first deletes old entries, then inserts new ones
+func (gs *GormStore) persistIndexEntries(resource model.Resource, oldResource
model.Resource) error {
+ db := gs.pool.GetDB()
+
+ // Delete old entries if updating
+ if oldResource != nil {
+ if err := db.Where("resource_key = ?",
oldResource.ResourceKey()).Delete(&ResourceIndexModel{}).Error; err != nil {
Review Comment:
copilot这里说的有点道理,index现在是所有kinds的resource都在一个表里,可以再加一个and条件过滤一下以防万一 @thunguo
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]