Skip to content

Commit

Permalink
fix: Pass index type for Scalar indexes (#696)
Browse files Browse the repository at this point in the history
Related to #694 #695

---------

Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia authored Apr 8, 2024
1 parent 59ff80c commit 6bb1f79
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion entity/index_scalar.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ type indexScalar struct {
}

func (i *indexScalar) Params() map[string]string {
return map[string]string{}
result := make(map[string]string)
if i.baseIndex.it != "" {
result[tIndexType] = string(i.baseIndex.it)
}
return result
}

func NewScalarIndex() Index {
Expand Down
8 changes: 8 additions & 0 deletions entity/index_scalar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ func TestScalarIndex(t *testing.T) {
oldScalarIdx := NewScalarIndex()

assert.EqualValues(t, "", oldScalarIdx.IndexType(), "use AUTO index when index type not provided")
_, has := oldScalarIdx.Params()[tIndexType]
assert.False(t, has)

idxWithType := NewScalarIndexWithType(Sorted)

assert.EqualValues(t, Sorted, idxWithType.IndexType())
assert.EqualValues(t, Sorted, idxWithType.Params()[tIndexType])

idxWithType = NewScalarIndexWithType(Trie)

assert.EqualValues(t, Trie, idxWithType.IndexType())
assert.EqualValues(t, Trie, idxWithType.Params()[tIndexType])
}

0 comments on commit 6bb1f79

Please sign in to comment.