Building simplicidade.org: notes, projects, and occasional rants

Tip: MySQL is not that helpful sometimes

Stupid problem today.

In a listing I had, I had a percent column. The problem was that the database definition for that column was wrong, it used DECIMAL(2,4). Yes, 100% will not fit in there. Also: this syntax was valid in 3.x but with 5.x you need DECIMAL(6,4). I'm using now DECIMAL(7,4) to fit the edge case.

My peeve with MySQL is that if I give him 100 to put in that column he will not complain nor store NULL. He will help you and store 99.9999.

But the problem was the lack of a test for the edge case. Added, committed, happy happy joy joy.