logoalt Hacker News

InsideOutSantayesterday at 8:57 PM1 replyview on HN

The developer's intention is that anything can go in there.

You would only inherit a project where everything was ANY if anything could go anywhere.

With SQLite's default behavior, anything can always go anywhere, so the type definitions are at best semi-accidentally observed by the code, and at worst completely misleading. You have no idea which of the two the developer intended.

I get the impression that this SQLite behavior is a historical oddity caused by the original use case for the tool, rather than something that was intentionally planned and thought through, and was later retconned to be intentional and benign. To me, it makes no sense, even after reading the explanation on sqlite's website.


Replies

jrapdx3today at 12:00 AM

IIRC SQLite originated as a Tcl extension. In Tcl at the user level "everything is a string" or a number. So it's logical SQLite would accept values as a string or number. Interestingly a Tcl function defines its own semantics, an input value means whatever the function says it means, perhaps a timestamp. SQLite inherited these attributes, and as many commenters observe, SQLite largely continues to work that way.

Implies documentation is crucial. Fortunately SQLite's documentation is among the best out there.