We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
描述 bug
项目中使用delete_time作为逻辑删除字段,默认为null值,经测试null值建立的唯一索引是不生效的,如下面的建表语句,仍然可以插入相同username的数据
CREATE TABLE lin_user ( id int(10) unsigned NOT NULL AUTO_INCREMENT, username varchar(24) NOT NULL COMMENT '用户名,唯一', nickname varchar(24) DEFAULT NULL COMMENT '用户昵称', avatar varchar(500) DEFAULT NULL COMMENT '头像url', email varchar(100) DEFAULT NULL COMMENT '邮箱', create_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), update_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), delete_time datetime(3) DEFAULT NULL, PRIMARY KEY (id), UNIQUE KEY username_del (username, delete_time), UNIQUE KEY email_del (email, delete_time) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
The text was updated successfully, but these errors were encountered:
如果把delete_time的默认值设为'9999-12-31 23:59:59.999'是不是一个可行的做法呢
delete_time
'9999-12-31 23:59:59.999'
Sorry, something went wrong.
No branches or pull requests
描述 bug
项目中使用delete_time作为逻辑删除字段,默认为null值,经测试null值建立的唯一索引是不生效的,如下面的建表语句,仍然可以插入相同username的数据
The text was updated successfully, but these errors were encountered: