diff --git a/CHANGELOG.md b/CHANGELOG.md index 247fc2e9..c5c14b8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,20 +1,18 @@ # Change Log ## [master](https://github.com/arangodb/go-driver/tree/master) (N/A) +- Fix `lastValue` field type ## [1.3.2](https://github.com/arangodb/go-driver/tree/v1.3.2) (2022-05-16) - - Fix selectivityEstimate Index field type ## [1.3.1](https://github.com/arangodb/go-driver/tree/v1.3.1) (2022-03-23) - - Add support for `exclusive` field for transaction options - Fix cursor executionTime statistics getter - Fix cursor warnings field type - Fix for DocumentMeta name field overrides name field ## [1.3.0](https://github.com/arangodb/go-driver/tree/v1.3.0) (2022-03-17) - - Disallow unknown fields feature - inBackground parameter in ArangoSearch links - ZKD indexes diff --git a/cluster.go b/cluster.go index 99f6f369..4a8e9361 100644 --- a/cluster.go +++ b/cluster.go @@ -256,9 +256,11 @@ type InventoryCollectionParameters struct { // Deprecated: since 3.7 version. It is related only to MMFiles. JournalSize int64 `json:"journalSize,omitempty"` KeyOptions struct { - AllowUserKeys bool `json:"allowUserKeys,omitempty"` - LastValue int64 `json:"lastValue,omitempty"` - Type string `json:"type,omitempty"` + AllowUserKeys bool `json:"allowUserKeys,omitempty"` + // Deprecated: this field has wrong type and will be removed in the future. It is not used anymore since it can cause parsing issues. + LastValue int64 `json:"-"` + LastValueV2 uint64 `json:"lastValue,omitempty"` + Type string `json:"type,omitempty"` } `json:"keyOptions"` // Deprecated: use 'WriteConcern' instead. MinReplicationFactor int `json:"minReplicationFactor,omitempty"` diff --git a/cluster_impl.go b/cluster_impl.go index 0f9f6257..ad10a73a 100644 --- a/cluster_impl.go +++ b/cluster_impl.go @@ -43,7 +43,7 @@ type cluster struct { conn Connection } -// LoggerState returns the state of the replication logger +// Health returns the state of the cluster func (c *cluster) Health(ctx context.Context) (ClusterHealth, error) { req, err := c.conn.NewRequest("GET", "_admin/cluster/health") if err != nil { @@ -64,7 +64,7 @@ func (c *cluster) Health(ctx context.Context) (ClusterHealth, error) { return result, nil } -// Get the inventory of the cluster containing all collections (with entire details) of a database. +// DatabaseInventory Get the inventory of the cluster containing all collections (with entire details) of a database. func (c *cluster) DatabaseInventory(ctx context.Context, db Database) (DatabaseInventory, error) { req, err := c.conn.NewRequest("GET", path.Join("_db", db.Name(), "_api/replication/clusterInventory")) if err != nil { @@ -290,7 +290,7 @@ type inventoryCollectionParametersInternal struct { JournalSize int64 `json:"journalSize,omitempty"` KeyOptions struct { AllowUserKeys bool `json:"allowUserKeys,omitempty"` - LastValue int64 `json:"lastValue,omitempty"` + LastValue uint64 `json:"lastValue,omitempty"` Type string `json:"type,omitempty"` } `json:"keyOptions"` // Deprecated: use 'WriteConcern' instead @@ -322,23 +322,35 @@ type inventoryCollectionParametersInternal struct { } func (p *InventoryCollectionParameters) asInternal() inventoryCollectionParametersInternal { + lastValue := p.KeyOptions.LastValueV2 + if lastValue == 0 && p.KeyOptions.LastValue != 0 { + lastValue = uint64(p.KeyOptions.LastValue) + } + return inventoryCollectionParametersInternal{ - CacheEnabled: p.CacheEnabled, - Deleted: p.Deleted, - DistributeShardsLike: p.DistributeShardsLike, - DoCompact: p.DoCompact, - GloballyUniqueId: p.GloballyUniqueId, - ID: p.ID, - IndexBuckets: p.IndexBuckets, - Indexes: p.Indexes, - InternalValidatorType: p.InternalValidatorType, - IsDisjoint: p.IsDisjoint, - IsSmart: p.IsSmart, - IsSmartChild: p.IsSmartChild, - IsSystem: p.IsSystem, - IsVolatile: p.IsVolatile, - JournalSize: p.JournalSize, - KeyOptions: p.KeyOptions, + CacheEnabled: p.CacheEnabled, + Deleted: p.Deleted, + DistributeShardsLike: p.DistributeShardsLike, + DoCompact: p.DoCompact, + GloballyUniqueId: p.GloballyUniqueId, + ID: p.ID, + IndexBuckets: p.IndexBuckets, + Indexes: p.Indexes, + InternalValidatorType: p.InternalValidatorType, + IsDisjoint: p.IsDisjoint, + IsSmart: p.IsSmart, + IsSmartChild: p.IsSmartChild, + IsSystem: p.IsSystem, + IsVolatile: p.IsVolatile, + JournalSize: p.JournalSize, + KeyOptions: struct { + AllowUserKeys bool `json:"allowUserKeys,omitempty"` + LastValue uint64 `json:"lastValue,omitempty"` + Type string `json:"type,omitempty"` + }{ + p.KeyOptions.AllowUserKeys, + lastValue, + p.KeyOptions.Type}, MinReplicationFactor: p.MinReplicationFactor, Name: p.Name, NumberOfShards: p.NumberOfShards, @@ -367,22 +379,32 @@ func (p *InventoryCollectionParameters) fromInternal(i inventoryCollectionParame func (p *inventoryCollectionParametersInternal) asExternal() InventoryCollectionParameters { return InventoryCollectionParameters{ - CacheEnabled: p.CacheEnabled, - Deleted: p.Deleted, - DistributeShardsLike: p.DistributeShardsLike, - DoCompact: p.DoCompact, - GloballyUniqueId: p.GloballyUniqueId, - ID: p.ID, - IndexBuckets: p.IndexBuckets, - Indexes: p.Indexes, - InternalValidatorType: p.InternalValidatorType, - IsDisjoint: p.IsDisjoint, - IsSmart: p.IsSmart, - IsSmartChild: p.IsSmartChild, - IsSystem: p.IsSystem, - IsVolatile: p.IsVolatile, - JournalSize: p.JournalSize, - KeyOptions: p.KeyOptions, + CacheEnabled: p.CacheEnabled, + Deleted: p.Deleted, + DistributeShardsLike: p.DistributeShardsLike, + DoCompact: p.DoCompact, + GloballyUniqueId: p.GloballyUniqueId, + ID: p.ID, + IndexBuckets: p.IndexBuckets, + Indexes: p.Indexes, + InternalValidatorType: p.InternalValidatorType, + IsDisjoint: p.IsDisjoint, + IsSmart: p.IsSmart, + IsSmartChild: p.IsSmartChild, + IsSystem: p.IsSystem, + IsVolatile: p.IsVolatile, + JournalSize: p.JournalSize, + KeyOptions: struct { + AllowUserKeys bool `json:"allowUserKeys,omitempty"` + LastValue int64 `json:"-"` + LastValueV2 uint64 `json:"lastValue,omitempty"` + Type string `json:"type,omitempty"` + }{ + p.KeyOptions.AllowUserKeys, + // cast to int64 to keep backwards compatibility for most cases + int64(p.KeyOptions.LastValue), + p.KeyOptions.LastValue, + p.KeyOptions.Type}, MinReplicationFactor: p.MinReplicationFactor, Name: p.Name, NumberOfShards: p.NumberOfShards, diff --git a/collection.go b/collection.go index 92342b75..36ca146d 100644 --- a/collection.go +++ b/collection.go @@ -116,8 +116,8 @@ type CollectionProperties struct { // AllowUserKeys; if set to true, then it is allowed to supply own key values in the _key attribute of a document. // If set to false, then the key generator is solely responsible for generating keys and supplying own key values in // the _key attribute of documents is considered an error. - AllowUserKeys bool `json:"allowUserKeys,omitempty"` - LastValue int64 `json:"lastValue,omitempty"` + AllowUserKeys bool `json:"allowUserKeys,omitempty"` + LastValue uint64 `json:"lastValue,omitempty"` } `json:"keyOptions,omitempty"` // NumberOfShards is the number of shards of the collection. // Only available in cluster setup.