On 07/03/2013 12:18 PM, Ryan Johnson wrote:
On 07/03/2013 11:14 AM, Doug Currie wrote:
On Mar 7, 2013, at 11:07 AM, Ryan Johnson
<ryan.john...@cs.utoronto.ca> wrote:
That does leave the question of what to do with cast ('1.0' as
integer), though. Without the prefix-based matching that would now
return NULL rather than 1, even though cast(1.0 as integer) would
still return 1. Then again, disallowing all floats might be better
than the current practice of returning 1 from a cast of both '1e-10'
and '1e10' (the real->integer casts do the right thing, as does
assignment to a column with integer affinity).
Would
cast(cast(x as real) as integer)
do what you want?
Looks like it, though I'd probably make the first cast be to numeric
(may as well go directly to int if you can).
It's also a bit more efficient (2 VDBE ops fewer) and less brittle
than the nasty hack I came up with:
x=cast(cast(x as numeric) as integer)
vs.
x+0=x and cast(x as integer)=x
Here's some more weirdness... typeof(cast('30e-1' as numeric)) returns
'integer' but casting 30e-1 returns 'real'. Same for '3.0' vs 3.0. And,
of course, casting 'abc' also yields an integer.
Ryan
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users