我使用的环境是
go version go1.11.1 windows/amd64
xorm + Sqlite3 作为数据驱动及储存
我在使用
type User struct {
Id int `json:"id" xorm:"pk autoincr unique(UNIQUE) INT(10) notnull"`
Name string `json:"name" xorm:"VARCHAR(50) notnull"`
}
user := new(User)
user.Name = "myname"
affected, err := engine.Insert(user)
插入数据时提示我
NOT NULL constraint failed: user.id
我上面有写 pk autoincr 字段
我在这卡壳了
有大神愿意帮我看看吗?
在线等,感谢!
你和我不一样。。 你这个 应该是没有把那个字段 设为自增吧