Skip to content

Scanner should return one of int64,float64,bool,[]byte,string,time.Time,nil , but I got uint64  #1575

Open
@bronze1man

Description

It maybe a bug of database/sql , if it is ,please tell me.

Issue description

https://pkg.go.dev/database/sql#Scanner says Scanner should return one of int64,float64,bool,[]byte,string,time.Time,nil , but I got uint64

Example code

the sql:

select * from INFORMATION_SCHEMA.TABLES

some of my scaner_t implement.

type scaner_t struct{
	src any
}
func (s *scaner_t) Scan(src any) error{
	s.src = src
	return nil
}
func (s *scaner_t) AsString() (outS string,err error){
	switch obj:=s.src.(type) {
	case int64:
		return strconv.FormatInt(obj,10),nil
	case float64:
		return strconv.FormatFloat(obj,'f',-1,64),nil
	case bool:
		return strconv.FormatBool(obj),nil
	case []byte:
		return string(obj),nil
	case string:
		return obj,nil
	case time.Time:
		b,err:=obj.MarshalText()
		if err!=nil{
			return "",err
		}
		return string(b),nil
	case nil:
		return "",nil
	default:
		return "",errors.New("unknow type "+fmt.Sprintf("%T",s.src))
	}
}

Error log

unknow type uint64

Configuration

Driver version (or git SHA):
github.com/go-sql-driver/mysql v1.8.0

Go version: run go version in your console
go version go1.19.2 darwin/amd64

Server version: E.g. MySQL 5.6, MariaDB 10.0.20

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.44    |
+-----------+

Server OS: E.g. Debian 8.1 (Jessie), Windows 10
mac os 14.2.1

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