This is an issue with kitkat
. I had such issue in past. I tried same cast query on 6.0 and it was working as expected. Try it on 6.0 .
But sqllite
supports casting and here is it's documentation about cast as integer etc.
But after a little more digging I found that most kitkat uses SQLite 3.7.11:
.Here is a link.
I found this page about versions of sqllite. They describe the issue they fixed in each version.
This is what they changed in 3.8.2
Changed the defined behavior for the CAST expression when floating point values greater than +9223372036854775807
are cast into into integers so that the result is the largest possible integer, +9223372036854775807
, instead of the smallest possible integer, -9223372036854775808
. After this change, CAST(9223372036854775809.0 as INT) yields +9223372036854775807
instead of -9223372036854775808
. ← Potentially Incompatible Change!
And then in 3.8.7
They improve optimization of CAST operators. And then I found this ticket which explain alot of what's really wrong. Now it's fixed might work or new device but with older devices you have to find some other solution. With this os issue, you cannot rely on cast query. Since you are not sure about which os version uses which SQL version. Hope it helps.