Hacker News

Tell HN: Cast('abc' AS INTEGER) returns 0 in SQLite

3 points by prmph ago | 5 comments
Every day I encounter more weirdness of SQLite. Is this the JavaScript of databases?

hans_castorp |next [-]

There is more: https://dbfiddle.uk/FDkqamR_

(Some examples there no longer work with the current version - so they are improving :) )

This is by design and well documented though.

kankalar54950 |next |previous [-]

[flagged]

kankalar54950 |next |previous [-]

[flagged]

vconnor |previous [-]

What do you want it to return? You should really RTFM of SQLite. It's by design.

prmph |root |parent [-]

It is not a good design. It should throw an error.

stefanos82 |root |parent [-]

Then declare your table(s) as strict; that should solve your issues.

https://sqlite.org/stricttables.html

prmph |root |parent [-]

Even with STRICT, explicit CAST() has the same problem.