Skip to content

textRows.Next returns only []byte Values #366

Closed
@binary132

Description

@binary132

I'm using the database/sql driver implementation on a *DB obtained using sql.Open.

My code looks a bit like this.

var dataRows []map[string]interface{}
for rowNum := 0; rows.Next(); rowNum++ {
        newMap := make(map[string]interface{})
        err = rows.MapScan(newMap)
        // ...
}

json.Marshal(dataRows)
// [{"id":"MQ==","name":"b28="},{"id":"Mg==","name":"cmVhbCBuYW1l"}]
// expected:
// [{"id":1,"name":"oo"},{"id":2,"name":"real name"}]

All values unmarshaled into dataRows are of []byte type, including numbers, strings, etc. This is causing problems.

Would you be open to a pull request implementing the type switch from binaryRows on textRows?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions