Re:Many small queries are efficient in SQLite
by clon on Tuesday February 16, 2021 @04:36AM
(#26152397)
You just put me off Sqlite for life. I can't believe someone thought this to be a good idea.
[ Parent
| on HN ]
Re:Many small queries are efficient in SQLite
by foepys on Tuesday February 16, 2021 @05:49AM
(#26152759)
SQLite just does what JavaScript and other weakly typed languages do. The developer is responsible for what they input. If type checks are a must, SQLite is just not for you, easy as that.
Re:Many small queries are efficient in SQLite
by LunaSea on Tuesday February 16, 2021 @07:33AM
(#26153276)
But event JavaScript will reject data if it's considered not valid for a type.
It won't throw but it will set an "invalid" / "NaN" / etc. value.
Re:Many small queries are efficient in SQLite
by foepys on Tuesday February 16, 2021 @08:04AM
(#26153457)
I don't see how having "NaN" or "undefined" in a number field makes any difference to just putting the value there. If you are using a strongly typed language, this will not be a problem.
SQLite made a design choice in favor of simplicity. It's also missing basic date functions all together. The only way to compare dates is by using Unix Epoch.
Re:Many small queries are efficient in SQLite
by samatman on Tuesday February 16, 2021 @05:19PM
(#26159473)
I use ISO 8601 full timestamps in UTC.
They were carefully designed so that collation order is identical to temporal order. Which is convenient!
If you need interval logic, though, SQLite won't help you, and epoch is the better choice. It's possible to solve some queries with a regex, but you won't love it.
Re:Many small queries are efficient in SQLite
by OskarS on Tuesday February 16, 2021 @10:01AM
(#26154446)
Chill out. This is a design choice to make it more viable to be used in dynamically typed languages. It's maybe not the design choice everyone would make, but it's not, like, insane: this is how all variables in Python/JavaScript/Ruby/whatever works.
If you really care about this, adding strongly typed columns is trivial: https://dbfiddle.uk/?rdbms=sqlite_3.27&fiddle=9baffa184672a7...