diff --git a/CHANGELOG.md b/CHANGELOG.md index 022d1552..ed20c7fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Use Go 1.19.4 - Add `IsExternalStorageError` to check for [external storage errors](https://www.arangodb.com/docs/stable/appendix-error-codes.html#external-arangodb-storage-errors) - `nested` field in arangosearch type View +- Fix: TTL index creation fails when expireAt is 0 ## [1.4.1](https://github.com/arangodb/go-driver/tree/v1.4.1) (2022-12-14) - Add support for `checksum` in Collections diff --git a/collection_indexes_impl.go b/collection_indexes_impl.go index fb29a6dc..d7255483 100644 --- a/collection_indexes_impl.go +++ b/collection_indexes_impl.go @@ -40,7 +40,7 @@ type indexData struct { Estimates *bool `json:"estimates,omitempty"` MaxNumCoverCells int `json:"maxNumCoverCells,omitempty"` MinLength int `json:"minLength,omitempty"` - ExpireAfter int `json:"expireAfter,omitempty"` + ExpireAfter int `json:"expireAfter"` Name string `json:"name,omitempty"` FieldValueTypes string `json:"fieldValueTypes,omitempty"` IsNewlyCreated *bool `json:"isNewlyCreated,omitempty"` diff --git a/test/index_ensure_test.go b/test/index_ensure_test.go index 170584d8..d056eb2f 100644 --- a/test/index_ensure_test.go +++ b/test/index_ensure_test.go @@ -447,6 +447,21 @@ func TestEnsureTTLIndex(t *testing.T) { } else if found { t.Errorf("Index '%s' does exist, expected it not to exist", idx.Name()) } + + // Create index with expireAfter = 0 + idx, created, err = col.EnsureTTLIndex(nil, "createdAt", 0, nil) + if err != nil { + t.Fatalf("Failed to create new index: %s", describe(err)) + } + if !created { + t.Error("Expected created to be true, got false") + } + if idxType := idx.Type(); idxType != driver.TTLIndex { + t.Errorf("Expected TTLIndex, found `%s`", idxType) + } + if idx.ExpireAfter() != 0 { + t.Errorf("Expected ExpireAfter to be 0, found `%d`", idx.ExpireAfter()) + } } // TestEnsureZKDIndex creates a collection with a ZKD index.