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 911f4ec252 - Show all commits

View File

@ -351,25 +351,19 @@ func (k Keeper) ProcessAttributes(ctx sdk.Context, record types.RecordType) erro
// #nosec G705 // #nosec G705
for key := range record.Attributes { for key := range record.Attributes {
attr := record.Attributes[key] attr := record.Attributes[key]
rt := reflect.TypeOf(attr) if reflect.Slice == reflect.TypeOf(attr).Kind() {
switch rt.Kind() { av := attr.([]interface{})
case reflect.Slice: for i := range av {
{ indexKey := GetAttributesIndexKey(key, av[i])
av := attr.([]interface{})
for i := range av {
indexKey := GetAttributesIndexKey(key, av[i])
if err := k.SetAttributeMapping(ctx, indexKey, record.ID); err != nil {
return err
}
}
}
default:
{
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
} }
} }
} else {
indexKey := GetAttributesIndexKey(key, attr)
if err := k.SetAttributeMapping(ctx, indexKey, record.ID); err != nil {
return err
}
} }
} }
} }