Remix.run Logo
andrewstuart 2 hours ago

Disturbing.

I did not know SQLite allows writing data that does not match the column type. Yuck. Now I need to review anything I built and fix it.

I understand why they wouldn’t, but STRICT should be the default.

lateforwork an hour ago | parent | next [-]

STRICT has severe limitations, for example it does not have date data type.

Why is it a problem that it allows data that does not match the column type? SQLite is intended for embedded databases, where only your application reads and writes from the tables. In this scenario, as long as you write data that matches the column's data type, data in the table does match the column type.

andrewstuart an hour ago | parent | next [-]

>> Why is it a problem that it allows data that does not match the column type?

“Developers should program it right” is less effective than a system that ensures it must be done right.

Read the comments in this thread for examples of subtle bugs described by developers.

lateforwork 31 minutes ago | parent [-]

> “Developers should program it right” is less effective than a system that ensures it must be done right.

You're right, of course. But this must be balanced with the fact that applications evolve, and often need to change the type of data they store. How would you manage that if this is an iOS app? If SQLite didn't allow you to store a different type of value than the column type, you would have to create a new table and migrate data to a new table. Or create a new column and abandon the old column. Your app updates will appear to not be smooth to users. So it is a tradeoff. The choice SQLite made is pragmatic, even if it makes some of us that are used to the guarantees offered by traditional RDBMSs queasy.

subhobroto an hour ago | parent | prev [-]

> Why is it a problem that it allows data that does not match the column type? SQLite is intended for embedded databases

I'm afraid people forget that SQLite is (or was?) designed to be a superior `open()` replacement.

It's great that modern SQLite has all these nice features, but if Dr. Hipp was reading this thread, I would assume he would be having very mixed feelings about the ways people mention using SQLite here.

SQLite 6 minutes ago | parent [-]

No, I think that people can use SQLite anyway they want. I'm glad people find it useful.

I do remain perplexed, though, about how people continue to think that rigid typing helps reliability in a scripting language (like SQL or JSON) where all values are subclasses of a single superclass. I have never seen that in my own practice. I don't know of any objective research that supports the idea that rigid typing is helpful in that context. Maybe I missed something...

subhobroto an hour ago | parent | prev [-]

> I understand why they wouldn’t, but STRICT should be the default.

No wait, what do you mean?

As I mentioned at https://news.ycombinator.com/item?id=47619982 - your application layer should be validating the data on its way in and out. I mention the two reasons I use for DB fall back