Be aware! Postgres rounds.
Yesterday, my pair and I created a test that calculated a value and compared that to the value of a calculation in the code we were testing. This worked out great except for one hitch, we were asserting about the derived value after it had been inserted into the database. What we didn't count on is that Postgres rounds. Check this out:
create table money (amount numeric(4, 2));
insert into money (amount) values (10.342) returning amount;
amount
--------
10.34
insert into money (amount) values (10.347) returning amount;
amount
--------
10.35
Postgres rounds!
Tweet