aerospike / aerospike-client-go

Aerospike Client Go
Apache License 2.0
433 stars 199 forks source link

GetObject slices bug: assign result of the append #302

Closed gdm85 closed 4 years ago

gdm85 commented 4 years ago

There is currently a bug happening when using GetObject(). See the following pseudo-code:

type MyObject struct {
    List []string
}

func testcase() {
    var o1, o2 MyObject
    o1.List = nil // the default is nil anyways
    o2.List = []string{}

    client.GetObject(nil, key, &o1)
    client.GetObject(nil, key, &o2)

    if len(o1.List) != len(o2.List) {
         panic("BUG: slice was not set properly")
    }
}

With the change proposed here the bug is fixed (the slice gets assigned); the assignment f = there is currently doing nothing.

There do not seem to be unit tests for this function, otherwise I would have added a regression test; perhaps I can contribute something on a separate PR.

khaf commented 4 years ago

Thanks for your PR. Merged in the latest release.