You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"fmt""gorm.io/driver/clickhouse""gorm.io/gorm"
)
typeUserstruct {
Uniqiduint8`gorm:"column:col1"`Namestring`gorm:"column:col2"`
}
func (User) TableName() string {
return"user"
}
funcmain() {
dsn:="clickhouse://user:passwd@localhost:9010/test?dial_timeout=10s&read_timeout=20s"rawDB, err:=gorm.Open(clickhouse.Open(dsn), &gorm.Config{})
iferr!=nil {
panic("failed to connect database")
}
rawDB.Exec("DROP TABLE IF EXISTS user")
err=rawDB.Exec(` CREATE TABLE user ( col1 UInt8 , col2 String , col3 Array(String) ) Engine = Memory`).Erroriferr!=nil {
panic(err)
}
u:=User{
Uniqid: 1,
Name: "gorm",
}
err=rawDB.Table("user").Create(&u).Erroriferr!=nil {
panic(err)
}
varraw []Usererr=rawDB.Table("user").Select("col1,col2").Find(&raw).Erroriferr!=nil {
panic(err) // works !!!
}
err=rawDB.Table("user").Find(&raw).Erroriferr!=nil {
panic(err) // panic: sql: Scan error on column index 2, name "col3": unsupported Scan, storing driver.Value type []string into type *sql.RawBytes
}
fmt.Println("Ok")
}
Description
If a non-base type exists in the table, Find will ret err:
`panic: sql: Scan error on column index 2, name "col3": unsupported Scan, storing driver.Value type []string into type *sql.RawBytes`
The text was updated successfully, but these errors were encountered:
GORM Playground Link
go-gorm/playground#1
Description
The text was updated successfully, but these errors were encountered: