Skip to content

Scan results are of wrong type when Query has no args #861

Closed
@ComaVN

Description

@ComaVN

Issue description

I tried to use Rows.Scan to read fields of an sql result row into variables of type interface{}

I expected integer sql types to be read as go type int64, or at least, the go type to be the same whatever the query looks like.

However:

  • SELECT 123 WHERE ? = 1 returns int64: 123
  • SELECT 123 WHERE 1 = 1 returns []uint8: []byte{0x31, 0x32, 0x33}

Example code

See https://github.com/ComaVN/gosqltypespoc for a PoC, and golang/go#27828 (comment) for why it's probably a mysql driver issue.

Error log

n/a

Configuration

No idea how to determine the driver version, see the PoC: I just download the latest version from github, I think.

go version go1.11 linux/amd64

mysql:8.0.12, mariadb:10.1

Debian GNU/Linux 9 (stretch)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions