4 ms·
The wacky approach to column types came from SQLite's origins of being closely integrated with Tcl. Knowing that doesn't somehow mean it was a good default wort
by frou_dh 2y ago
The wacky approach to column types came from SQLite's origins of being closely integrated with Tcl. Knowing that doesn't somehow mean it was a good default worth carrying on for decades.
- deleted 2y ago[deleted]
- bruce511 2y agoFirstly, while it's the default, it's not mandatory. As the author discovered you can use STRICT to make the columns typed, and types to be enforced. The reason it remains unaltered by default is because one of the goals (and accomplishments) of SQLite is that the on-disk-data-file is completely backwards compatible, and cross-platform. This is a very important feature in some situations, and not lightly tossed aside because some old default or system is not in vogue anymore.
- mpalmer 2y agoPut another way, "default to what's best for all users collectively" is not strictly equivalent to "default to what's most intuitive to unfamiliar users". The latter is the luxury of end-user software unburdened by decades of legacy compatibility obligations.
- SahAssar 2y agoSTRICT only works for simple types though as the article noted, so you can't do CREATE TABLE mytable ( id INTEGER PRIMARY KEY, created DATETIME, mything JSON ) STRICT;
- c0wb0yc0d3r 2y agoThat's the point of STRICT isn't it? 2 of the 3 types in your SQL statement aren't valid sqlite data types.
- SahAssar 2y agoThe point is that they are types supported by most other sql databases and supported as input/output by sqlite functions, but you can't validate that stored data is the correct type.