mongodb/mongo-perl-driver — pull request #32 by wjackson (2012-05-22 02:27:50+00:00)
Title: sometimes floats persist as ints

Fix for this bug: https://rt.cpan.org/Public/Bug/Display.html?id=77267

From that bug report:

It turns out that if you take a scalar that holds a float, use it as an int, store it
as the value for a Moose attribute, insert the value of the Moose attribute into
Mongo, then it's stored as a NumberLong instead of a float inside Mongo.

All those steps cause the about-to-be-inserted scalar to look like this according to
Devel::Peek:

SV = PVMG(0x21b8630) at 0x21abf98
REFCNT = 1
FLAGS = (PADMY,NOK,pIOK,pNOK)
IV = 1
NV = 1.25
PV = 0

Apparently, under these circumstances MongoDB is choosing to pass the IV to Mongo
instead of the NV. This seems like the wrong choice.