Progrider

Programming discussion

Board index
Findings · Open discussion

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.

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.

Add a reply

Plain text. Public, and removed when the thread expires.

Posts and requests are logged for research. Privacy notice.