mongoosejs / mongoose-double

Provides Double support for mongoose.js
MIT License
18 stars 13 forks source link

fix: prevent CastError being triggered by literal NaN #16

Open jdbdnz opened 1 year ago

jdbdnz commented 1 year ago

Overview

NaN is a valid value in MongoDB for Number type attributes (i.e. doubles). This change is necessary to avoid superfluous errors when loading records with NaN values in number fields.

Previous behavior:

New behavior:

Changes

Thoughts

I think the decision to accept NaN as a valid number type in MongoDB is dubious, I don't see a valid reason for wanting to store it. That said, the world is imperfect and so is the data we deal with.

My judgement here is that it is better to handle the imperfections gracefully. Feel free to close if you don't agree, and I'll just keep using my fork.

jdbdnz commented 1 year ago

I could see a case being made for removing the CastError entirely; instead writing non-numbers as NaN. I don't want to make it though.

jdbdnz commented 3 months ago

@vkarpov15 are you interested in this change, or should I close this?