Info
Instead of doing
primary_doc == secondary_doc #hooks.py
to compare 2 documents, we should check that each field is of the same type. We could miss things like:
>>> -9.223372036854776e+18 == -9223372036854775808
True
Top User Comments
xgen-internal-githook commented on Mon, 25 Jan 2016 17:38:14 +0000:
Author:
{u'username': u'mgrundy', u'name': u'Mike Grundy', u'email': u'michael.grundy@10gen.com'}
Message: SERVER-21801 CheckReplDBHash testing hook should check document type (resmoke.py)
(cherry picked from commit ca39291d733cb2171be6bddcdda8ace8851b1906)
Branch: v3.2
https://github.com/mongodb/mongo/commit/30b0de8351b6050925835cb8c211740d54abbe24
xgen-internal-githook commented on Fri, 22 Jan 2016 16:44:14 +0000:
Author:
{u'username': u'mgrundy', u'name': u'Mike Grundy', u'email': u'michael.grundy@10gen.com'}
Message: SERVER-21801 CheckReplDBHash testing hook should check document type (resmoke.py)
Branch: master
https://github.com/mongodb/mongo/commit/ca39291d733cb2171be6bddcdda8ace8851b1906
behackett commented on Thu, 10 Dec 2015 16:39:57 +0000:
I suppose you could create a new subclass of dict to do that, or monkey patch SON, but we wouldn't make that change in PyMongo. SON works like OrderedDict:
>>> 1.0 == 1
True
>>> {'a': 1} == {'a': 1.0}
True
>>> from collections import OrderedDict
>>> OrderedDict([('a', 1)]) == OrderedDict([('a', 1.0)])
True
max.hirschhorn@10gen.com commented on Thu, 10 Dec 2015 14:59:29 +0000:
One option is to extend the bson.SON class and override the __eq__() method to make it check that the types of the values are also equal. Effectively we want bson.SON([('a', int(1))]) == bson.SON([('a', float(1))]) to return false instead of true.
behackett, thoughts?
robert.guo commented on Tue, 8 Dec 2015 22:06:51 +0000:
Oops, I forgot to mention this was Python code.
milkie commented on Tue, 8 Dec 2015 20:12:00 +0000:
Triple equals to the rescue?