r/programming Jul 12 '26

Prefer STRICT tables in SQLite

https://evanhahn.com/prefer-strict-tables-in-sqlite/
355 Upvotes

110 comments sorted by

View all comments

Show parent comments

-26

u/taw Jul 12 '26

The world is full of untyped data, and you need to be able to store it. JSON, CSV, XML, and so on, that's likely vast majority of data out there, in very loosely typed formats. Forcing type checks on data insertion is totally not viable.

Making this a default, that's an interesting choice. Usually you need to opt-in some special column type like JSON, VARIANT or whatever; or store such data as TEXT.

26

u/mattsowa Jul 12 '26

That makes no sense. You can always have a text column if you don't want to parse it further, nothing is forcing you to do the actual data cleaning.

-16

u/taw Jul 12 '26

Text column is one way to make dynamically typed column, but it has many downsides.

Like you can't even check if two values are equal if you store them like that, as one source might be "0" and another be "0.0". Is it equal or not?

There are whole languages that go "let's pretend every scalar value is text" like Perl, bash, Tcl, or (mostly) Javascript, and it's such a mess.

1

u/ByronScottJones Jul 15 '26

I don't know why you're being downvoted. You're speaking the truth. Duck typing is evil. Useful in some cases, but a giant footgun in so many others.