This happened many years ago. I don't remember the details very well. I was a lot younger, working on a side project. I think I was testing if my app was handling errors properly, and it wouldn't throw an error when it should've.
I went through the usual debugging process, combing the code for logic errors and inspecting values along the way. It never crossed my mind that the problem was related to SQLite not enforcing fk constraints. Only after I was sure all my code worked as intended that I decided to hand-create an empty database and simulate query after query to trigger the bug. After seeing the weird behavior, I Googled something like "SQLite foreign key not working" and found the answer on a stack overflow question. I was absolutely dumbfounded.
It took me a few hours because I debugged everything besides SQLite. If I had known from the start it was related to foreign keys, it would've only taken me minutes. And I only found out about this because I was testing my error paths; I can imagine a world where I didn't test everything properly, and would spend a lot more time trying to figure out why my database was in a seemingly impossible state.
That last point you made is what makes it so terrifying IMO. My example with Alice inheriting Bob's post is completely plausible by totally normal SQLite usage; you just need to introduce one minor bug in your code at some point in time, and suddenly you have a row in one table referencing the wrong row in another table and the app keeps working normally. Silent, undetectable data corruption.
Somehow you've exactly captured the argument against your position.
Yeah, we all know too... But it's not what sqlite does and that is weird and confusing and not necessary. Just because you know how to figure it out doesn't justify the behavior of the system.
They're stuck in the decades old method of "RTFM" instead of "provide sensible defaults". I fear using any library or software they've had a hand in writing
View all comments
Show parent comment
9
u/mort96 Jul 16 '26
You don't know the symptoms /u/j_sidharta was experiencing, nor do I.