Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Currently, developers calling the
Codec.Native
functions need to write glue code to traverse the returnedmap[string]interface{}
s and convert the values. While this approach makes sense for maintaining the symmetry between the encoder input and the decoder output and for its reflection of the underlying architecture of the format, it creates some unnecessary friction in applications where the goal is simply to get data into simple, native types.Background
I recently created a Go SDK for DataStax Astra which provides methods for developers to work with returned data without worrying about the underlying API. It implements a
Scan
function that mirrors the functionality of the builtindatabase/sql#Rows.Scan
function. I think a similar approach might be useful here.convertAssign
: datastax-ext/astra-go-sdk#15Row.Scan
: datastax-ext/astra-go-sdk#16Future Work
testBinaryScan
function and add more test cases.Codec
function to expose the field name order. Unlike the case whereScan
calls follow database queries, schemas may be loaded from outside the code and the field order may not be visible to developers. Giving developers access to the field name order would allow them to create runtime mappings between fields and destinations (example)