Skip to content

Commit

Permalink
Test another case
Browse files Browse the repository at this point in the history
  • Loading branch information
islamaliev committed Feb 29, 2024
1 parent bc6d5d6 commit fa956bd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/sourcenetwork/immutable"

"github.com/sourcenetwork/defradb/client"
"github.com/sourcenetwork/defradb/client/request"
"github.com/sourcenetwork/defradb/encoding"
)

Expand Down Expand Up @@ -274,7 +275,9 @@ func normalizeIndexDataStoreKeyValues(key *IndexDataStoreKey, fields []client.Fi
var val any
if i == len(key.fields)-1 && len(key.fields)-len(fields) == 1 {
bytes, ok := key.fields[i].Value.([]byte)
ok = ok
if !ok {
return client.NewErrUnexpectedType[[]byte](request.DocIDArgName, key.fields[i].Value)
}
val = string(bytes)
} else {
val, err = NormalizeFieldValue(fields[i], key.fields[i].Value)
Expand Down
5 changes: 5 additions & 0 deletions core/key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,11 @@ func TestDecodeIndexDataStoreKey_InvalidKey(t *testing.T) {
val: encodeKey(colID, indexID, 5, false, 7, false, 9, false),
numFields: 2,
},
{
name: "invalid docID value",
val: encoding.EncodeUvarintAscending(append(encodeKey(colID, indexID, 5, false), '/'), 5),
numFields: 1,
},
}
indexDesc := client.IndexDescription{ID: indexID, Fields: []client.IndexedFieldDescription{{}}}
for _, c := range cases {
Expand Down

0 comments on commit fa956bd

Please sign in to comment.