2 ms·
I like SQLite. But I really wish its default behavior wasn't to simply allow garbage data into the database. If I have an int column, don't let me accidentally
by mort96 4y ago
I like SQLite. But I really wish its default behavior wasn't to simply allow garbage data into the database. If I have an int column, don't let me accidentally store a string.
- eesmith 4y agohttps://www.sqlite.org/stricttables.html https://www.sqlite.org/stricttables.html "In a CREATE TABLE statement, if the "STRICT" table-option keyword is added to the end, after the closing ")", then strict typing rules apply to that table. ... The STRICT keyword at the end of a CREATE TABLE statement is only recognized by SQLite version 3.37.0 (2021-11-27) and later. sqlite> create table x (a int); sqlite> insert into x values ('hello'); sqlite> select * from x; hello sqlite> drop table x; sqlite> create table x (a int) strict; sqlite> insert into x values ('hello'); Runtime error: cannot store TEXT value in INT column x.a (19)
- mort96 4y agoYeah, I know about that, and I'm doing that on all my tables these days. It's just sad that the default behaviour is to allow garbage data, and that if you ever forget to put 'strict' on your tables you'll have a perfectly functional application with no sign that anything is wrong until you suddenly find corrupt data in your database.
- euroderf 4y agocreate table strict