mongodb/bson-erlang — pull request #2 by anneli (2012-03-02 06:29:32+00:00)
Title: Store the atom 'undefined' as BSON null; recover BSON null as 'undefined'

Hi all,

I'd be interested for feedback on this commit.

Instead of storing the `undefined` atom as a BSON string `"undefined"`, we store it as a BSON null. Similarly, BSON nulls are read in as `undefined` atoms, rather than `null` atoms, which have no significance in Erlang.

This seems to preserve semantics as well as possible. I note an "undefined" type in the BSON spec, which this module rightly ignores due to its deprecation.

I'm just looking to close the semantic gap a little more between Erlang and BSON—currently if an undefined atom slips into any data, you end up with `"undefined"` in the object, and once you read things back in you get `<<"undefined">>`s cropping up all over. This seeks to avoid that issue.

Cheers,

A