4 ms·
> Foreign Key Enforcement Is Off By Default That is by far my biggest annoyance with sqlite. Not only that, but the FK enforcement must be enabled on a per-co
by masklinn 4y ago
> Foreign Key Enforcement Is Off By Default
That is by far my biggest annoyance with sqlite.
Not only that, but the FK enforcement must be enabled on a per-connection basis. Unlike the WAL, you can’t just set it once and know that your FKs will be checked, every client must set the pragma on every connection. Such a pain in the ass.
The error reporting on FK constraint errors is also not great (at least when using implicit constraints via REFERENCES sqlite just reports that an FK constraint failed, no mention of which or why, good luck, have fun).
More generally, I find sqlite to have worse error messages than postgres when feeding it invalid SQL.
- jeffreyrogers 4y agoCan't you just wrap the connection handling code with some logic that automatically executes the pragma?
- masklinn 4y agoSure. The problem is that you have to carefully remember to do that in every project, and if other applications need write access that they do so as well.
- massysett 4y agoThere is a compile-time option to always enable foreign-key constraints.