Posts Tagged ‘null’

* Dude, you’re so, like, negative (zero)

Posted on April 23rd, 2009 by whinger. Filed under Tech, Web Development, Whinges.


Edit: this is fixed in 5.1.30, so I’m guessing it was fixed a while back – I’m working on a legacy system using 5.0.15.

 

So MySQL thinks that

SELECT -COALESCE(null, 0);

should return -0

(Whatever -0 is)…

Clearly I’ve simplified my code and there are ways around this, but… WTF?

 

For what it’s worth,

SELECT -COALESCE(null, 0) + 0;

results in the expected “0” value.

 

I was disappointed that

SELECT -COALESCE(null, -0);

doesn’t work though – if you’re going to believe that -0 is a valid number, you should be able to get +0 out of it.

Tags: , , , , , .



Blogroll

Categories