Shall we use ObjectID or string id? #156

nagyv opened this Issue Nov 14, 2012 · 4 comments


None yet
2 participants

nagyv commented Nov 14, 2012

I've started to fix mongodb-engine to get it working with recent versions of toolbox. After blindly fixing the compiler, I've decided to have a look at the pre-existing test cases.

Quite a few of them were failing due to the fact that the returned is a unicode string, instead of an ObjectID. As a result, I could make many failing tests pass by the following assertions:

class AssertionsMixin(object):

    def assertEqualModels(self, model1, model2, message=None):
        self.assertEqual(, ObjectId(, message)

    def assertEqualModelsList(self, model1, model2, message=None):
        model1_pks = map(attrgetter('pk'), model1)
        model2_pks = map(ObjectId, map(attrgetter('pk'), model2))
        self.assertEqualLists(model1_pks, model2_pks)

Is there any reason to prefer ObjectID or plain strings above the other? The test in fails, because it returns ObjectID keys in the resulting dictionary.

It might be easier to stick with ObjectID instead of unicode ids. What do you think? Is there any prior knowledge on this topic?


jonashaag commented Nov 14, 2012 Where did you find that file?

btw, all three branches (1.3, 1.4, 1.5) of MongoDB Engine should work with the matching djangotoolbox versions.

nagyv commented Nov 14, 2012

sorry, it was the lookup module under the tests package

my version is here, it was forked today from master, and run against a virtualenv containing the master of djangotoolbox

nagyv commented Nov 15, 2012

err, I've checked djangotoolbox versions again, but could not find any

I would be glad if you could help me in finding the matching branches though

these are my guesses:

django compatibility django-nonrel djangotoolbox mongodb-engine
1.3 master ? master
1.4 master of nonrel 1.4 features/django-1.4 1.4
1.5 master of nonrel 1.5 1.5 1.5

Am I right with the above table? What branch should I use for django-nonrel 1.3?

As I've heard that the 1.3 branches are the most stable, I would prefer to have that installed first, and would try to fix the 1.4 branch - if necessary - afterwards.


jonashaag commented Nov 15, 2012

Follow these instructions for 1.3

Or, if you want to have the latest 1.3.X minor release, go with master/master/master for django/toolbox/mongodb-engine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment