go-xorm / xorm

Simple and Powerful ORM for Go, support mysql,postgres,tidb,sqlite3,mssql,oracle, Moved to https://gitea.com/xorm/xorm
BSD 3-Clause "New" or "Revised" License
6.67k stars 754 forks source link

mysql 如果列类型为text转 go的 net.IP 类型出错 #1094

Open qianxiansheng90 opened 6 years ago

qianxiansheng90 commented 6 years ago

type Test struct { ID int64 Name string Address string TT time.Time Other interface{} xorm:"json" Host net.IP xorm:"TEXT" }

eng1.SetMapper(core.GonicMapper{})
eng1.Sync2(new(Test))

eng1.ShowSQL(true)
eng1.Logger().SetLevel(core.LOG_DEBUG)
defer eng1.Close()
tests := []Test{}
err=eng1.Where("id>?",0).Find(&tests)
fmt.Println(err)

报错: [xorm] [info] 2018/09/11 12:40:36.209004 [SQL] SELECT id, name, address, tt, other, host FROM test WHERE (id>?) []interface {}{0} invalid character 's' looking for beginning of value

qianxiansheng90 commented 6 years ago

驱动是mysql: mysql表结构: CREATE TABLE test ( id bigint(20) NOT NULL AUTO_INCREMENT, name varchar(255) DEFAULT NULL, address varchar(255) DEFAULT NULL, tt datetime DEFAULT NULL, other text, host text, PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8