diff --git a/entity/index_scalar.go b/entity/index_scalar.go index a8c43a4a..ffaa5de9 100644 --- a/entity/index_scalar.go +++ b/entity/index_scalar.go @@ -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 { diff --git a/entity/index_scalar_test.go b/entity/index_scalar_test.go index 4107e8ff..5442f0d3 100644 --- a/entity/index_scalar_test.go +++ b/entity/index_scalar_test.go @@ -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]) }