Menu

Rust solved the compatibility trap with editions
📰

Rust solved the compatibility trap with editions

DEV Community: rust·RC·about 3 hours ago
#JKFmysgu
#devtorust#devto#dev#sqlite#author
Reading 0:00
15s threshold

Delete a user from a stock SQLite database, forget to delete their posts, and nothing complains. Insert a new user afterward and, because SQLite recycles ROWIDs, that account can take the integer ID the deleted user held. The orphaned posts then join cleanly to the new account. The author's example runs it end to end: Bob writes "Hello, I am Bob" and deletes his account, Alice signs up and gets Bob's recycled ID, and a join across the users and posts tables returns "Alice | Hello, I am Bob." No error fires at any step.

The cause is the first of several SQLite defaults the author argues are simply wrong: foreign key constraints are ignored unless you enable them with PRAGMA foreign_keys = ON . As far as the author knows, SQLite is the only RDBMS that doesn't enforce them out of the box. With the pragma on, that stray DELETE fails with "FOREIGN KEY constraint failed (19)" instead of quietly corrupting the join.

Type affinity is the second. A column declared INTEGER isn't restricted to integers.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.