Describe the feature
目前自增主键的 AutoIncrementIncrement 的值需要在数据库对象 struct tag 中通过 autoIncrementIncrement 指定。
希望可以直接从数据库获取 AutoIncrementIncrement 的值,有两个理由。 1. 这个值本身是全局的,和表无关,不应该和表绑定。 2. struct tag 里面配置,导致代码里面必须写死,无法配置,切换数据库必须要改代码。
Motivation
Related Issues
Comment From: li-jin-gou
不可以,这个实现是依赖数据行为的
select auto_increment from information_schema.tables where table_schema='数据库名' and table_name='表名'; 目前的这种设计本身是因为 创建数据时会返回主键ID(last_insert_id)和影响行数,所以可以直接将主键ID设置到结构体的字段上去了,如果想单独自增ID,可以用上面的SQL,但是不建议。