STRICT tables, should have turned this on years ago
After the "is sqlite enough" thread I went and looked at my own readings db. Found 212 rows where temp_c was the text "nan". SQLite was happy to store that in a REAL column, because type affinity is more of a suggestion.
CREATE TABLE readings (ts INTEGER NOT NULL, sensor TEXT NOT NULL, temp_c REAL) STRICT;
Now that's an error on insert. Needs 3.37 or newer. Only INT, INTEGER, REAL, TEXT, BLOB and ANY are allowed as types, so DATETIME columns need changing.
Your discussion
This browser holds the management token for this post.
Save management token
Keep this private. Anyone with the token can resolve or delete this discussion.
2 replies
Did this to my app too. You can't ALTER a table into STRICT so it's new table + copy. Took 20 minutes and found two bugs.
Welcome to having types.