Copilot commented on code in PR #1372:
URL: https://github.com/apache/dubbo-admin/pull/1372#discussion_r2636773103
##########
pkg/store/dbcommon/gorm_store.go:
##########
@@ -65,6 +66,11 @@ func (gs *GormStore) Init(_ runtime.BuilderContext) error {
if err :=
db.Scopes(TableScope(gs.kind.ToString())).AutoMigrate(&ResourceModel{}); err !=
nil {
return fmt.Errorf("failed to migrate schema for %s: %w",
gs.kind.ToString(), err)
}
+ // Register indexers for the resource kind
+ indexers := index.IndexersRegistry().Indexers(gs.kind)
+ if err := gs.AddIndexers(indexers); err != nil {
+ return err
+ }
Review Comment:
Consider adding a comment explaining why indexers must be registered before
calling rebuildIndices. This is a critical ordering requirement -
rebuildIndices iterates through all resources and uses the indexers to populate
the indices. Without indexers being registered first, the rebuild operation
would silently succeed but create no indices, leading to failures when querying
by index later.
--
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]