Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 5 additions & 3 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
92 changes: 57 additions & 35 deletions cluster_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down