yjqiang
V2EX  ›  分享发现

sqlite 对 INTEGER PRIMARY KEY 的 null 输入是真的骚气。。。

By yjqiang at 2019 年 2 月 5 日 · 2241 次点击
https://www.sqlite.org/lang_createtable.html#rowid

“ If an INSERT statement attempts to insert a NULL value into a rowid or integer primary key column, the system chooses an integer value to use as the rowid automatically. A detailed description of how this is done is provided separately.”
我表示有点难以接受这个“ feature ”,如果是 int 且 pk 情况下,无论你是否允许 null 输入,都会成功 insert,而且当年 null 输入时,自增 id ( Autoincrement )且无论你是否设置开启了自增功能。
折腾了我一晚上,大家觉得这是一个合理 feature 么?
2 条回复  •  2019-02-06 17:58:40 +08:00
wd
   1
wd  
   2019 年 2 月 6 日 via iPhone
这其实没什么好吐槽的,各种软件多少都会有一些开发者觉得合理的设定,你有你的道理,他们有他们的,学习掌握就好了,没办法。实在不服气自己改代码做自己想做的
yjqiang
   2
yjqiang  
OP
   2019 年 2 月 6 日
@wd 就是感觉有点骚气。。。用还是要用的(真香)毕竟比较小型化
© 2026 V2EX · 25ms · 3.9.8.5