Skip to content

Commit 98669d7

Browse files
authored
GT-336 TTL index creation fails when expireAt is 0 - fix (#467)
1 parent 5a55b22 commit 98669d7

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Use Go 1.19.4
55
- Add `IsExternalStorageError` to check for [external storage errors](https://www.arangodb.com/docs/stable/appendix-error-codes.html#external-arangodb-storage-errors)
66
- `nested` field in arangosearch type View
7+
- Fix: TTL index creation fails when expireAt is 0
78

89
## [1.4.1](https://github.com/arangodb/go-driver/tree/v1.4.1) (2022-12-14)
910
- Add support for `checksum` in Collections

collection_indexes_impl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type indexData struct {
4040
Estimates *bool `json:"estimates,omitempty"`
4141
MaxNumCoverCells int `json:"maxNumCoverCells,omitempty"`
4242
MinLength int `json:"minLength,omitempty"`
43-
ExpireAfter int `json:"expireAfter,omitempty"`
43+
ExpireAfter int `json:"expireAfter"`
4444
Name string `json:"name,omitempty"`
4545
FieldValueTypes string `json:"fieldValueTypes,omitempty"`
4646
IsNewlyCreated *bool `json:"isNewlyCreated,omitempty"`

test/index_ensure_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,21 @@ func TestEnsureTTLIndex(t *testing.T) {
447447
} else if found {
448448
t.Errorf("Index '%s' does exist, expected it not to exist", idx.Name())
449449
}
450+
451+
// Create index with expireAfter = 0
452+
idx, created, err = col.EnsureTTLIndex(nil, "createdAt", 0, nil)
453+
if err != nil {
454+
t.Fatalf("Failed to create new index: %s", describe(err))
455+
}
456+
if !created {
457+
t.Error("Expected created to be true, got false")
458+
}
459+
if idxType := idx.Type(); idxType != driver.TTLIndex {
460+
t.Errorf("Expected TTLIndex, found `%s`", idxType)
461+
}
462+
if idx.ExpireAfter() != 0 {
463+
t.Errorf("Expected ExpireAfter to be 0, found `%d`", idx.ExpireAfter())
464+
}
450465
}
451466

452467
// TestEnsureZKDIndex creates a collection with a ZKD index.

0 commit comments

Comments
 (0)