129: Index multivalued attributes. #128

Merged
telackey merged 4 commits from telackey/tags into main 2023-12-19 06:55:12 +00:00
Showing only changes of commit 61169a43c0 - Show all commits

View File

@ -354,19 +354,21 @@ func (k Keeper) ProcessAttributes(ctx sdk.Context, record types.RecordType) erro
rt := reflect.TypeOf(attr) rt := reflect.TypeOf(attr)
switch rt.Kind() { switch rt.Kind() {
case reflect.Slice: case reflect.Slice:
av := attr.([]interface{}) {
for i := range av { av := attr.([]interface{})
indexKey := GetAttributesIndexKey(key, av[i]) for i := range av {
k.Logger(ctx).Error(fmt.Sprintf("attr indexKey: %s", indexKey)) indexKey := GetAttributesIndexKey(key, av[i])
if err := k.SetAttributeMapping(ctx, indexKey, record.ID); err != nil { if err := k.SetAttributeMapping(ctx, indexKey, record.ID); err != nil {
return err return err
}
} }
} }
default: default:
indexKey := GetAttributesIndexKey(key, attr) {
k.Logger(ctx).Error(fmt.Sprintf("attr indexKey: %s", indexKey)) indexKey := GetAttributesIndexKey(key, attr)
if err := k.SetAttributeMapping(ctx, indexKey, record.ID); err != nil { if err := k.SetAttributeMapping(ctx, indexKey, record.ID); err != nil {
return err return err
}
} }
} }
} }