Skip to content

Commit fc85307

Browse files
authored
Fix selectivityEstimate Index field type (#397)
1 parent 477d962 commit fc85307

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Change Log
22

33
## [master](https://github.com/arangodb/go-driver/tree/master) (N/A)
4+
- Fix selectivityEstimate Index field type
45

56
## [1.3.1](https://github.com/arangodb/go-driver/tree/v1.3.1) (2022-03-23)
67
- Add support for `exclusive` field for transaction options

collection_indexes_impl.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type indexData struct {
4343
Name string `json:"name,omitempty"`
4444
FieldValueTypes string `json:"fieldValueTypes,omitempty"`
4545
IsNewlyCreated *bool `json:"isNewlyCreated,omitempty"`
46-
SelectivityEstimate int `json:"selectivityEstimate,omitempty"`
46+
SelectivityEstimate float64 `json:"selectivityEstimate,omitempty"`
4747
BestIndexedLevel int `json:"bestIndexedLevel,omitempty"`
4848
WorstIndexedLevel int `json:"worstIndexedLevel,omitempty"`
4949

test/indexes_test.go

+31
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"time"
3030

3131
driver "github.com/arangodb/go-driver"
32+
"github.com/stretchr/testify/require"
3233
)
3334

3435
// TestDefaultIndexes creates a collection without any custom index.
@@ -579,3 +580,33 @@ func TestTTLIndexesClusterInventory(t *testing.T) {
579580
}
580581

581582
}
583+
584+
func TestPersistentIndexCreation(t *testing.T) {
585+
c := createClientFromEnv(t, true)
586+
skipBelowVersion(c, "3.7", t)
587+
588+
db := ensureDatabase(nil, c, "index_test_creation", nil, t)
589+
coll := ensureCollection(nil, db, "index_creation_test_col", nil, t)
590+
591+
for i := 0; i < 16; i++ {
592+
_, err := coll.CreateDocument(context.Background(), map[string]interface{}{
593+
"MyIndex": fmt.Sprintf("%d", i),
594+
"Index": i,
595+
})
596+
require.NoError(t, err)
597+
}
598+
599+
for i := 0; i < 100; i++ {
600+
index, _, err := coll.EnsurePersistentIndex(
601+
context.Background(),
602+
[]string{"sensitivity"},
603+
&driver.EnsurePersistentIndexOptions{
604+
Unique: false,
605+
Sparse: false,
606+
Name: "idx_sensitivity",
607+
},
608+
)
609+
require.NoError(t, err)
610+
require.NotNil(t, index)
611+
}
612+
}

0 commit comments

Comments
 (0)