xorm使用Sqlite3驱动主键无法自增

我使用的环境是

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 字段
我在这卡壳了
有大神愿意帮我看看吗?
在线等,感谢!

阅读 3.4k
1 个回答

你和我不一样。。 你这个 应该是没有把那个字段 设为自增吧

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题