fabioberger / airtable-go

Golang client library for the Airtable API
MIT License
44 stars 29 forks source link

Seeing re-use of elements for ListRecords #3

Closed jasonparekh closed 7 years ago

jasonparekh commented 7 years ago

If I pass a []Row, where Row is:

type Row struct {
    AirtableID string `json:"id,omitempty"`
    Fields     map[string]interface{} `json:"fields"`
}

I end up having data cross the row boundary. If I switch it to an []interface{} or remove the optimization of it only creating tempRecordsHolder once, I get the correct behavior.

I've read the json.Unmarshal doc and agree it sounds like it shouldn't be re-using any values, but it looks like it is.

fabioberger commented 7 years ago

Thanks for the issue @jasonparekh. I've updated stubbedTests to include calling ListRecords two times in a row and did not encounter your issue (https://github.com/fabioberger/airtable-go/blob/master/tests/stubbed_tests/client_test.go#L64).

It's important to note though that the current behavior is that passing the same []Row instance into two calls of ListRecords would cause the results to be appended and not overwritten. Is this the unexpected behavior you've encountered?

Thanks again!