[MODM-86] Order of keys in embedded document need to be enforced Created: 11/Oct/10  Updated: 24/Nov/10  Resolved: 24/Nov/10

Status: Resolved
Project: Doctrine MongoDB ODM
Component/s: Persister
Affects Version/s: 1.0.0ALPHA1, 1.0.0ALPHA2, 1.0.0BETA1
Fix Version/s: 1.0.0BETA2

Type: Improvement Priority: Major
Reporter: Bulat Shakirzyanov Assignee: Bulat Shakirzyanov
Resolution: Fixed Votes: 0
Labels: None


Order of keys in embedded bson hashes in mongodb matters, so you can't $pullAll an embedded document if the order of keys is different from the one in mongodb:

_id: ObjectId('123'),
addresses: [

{ street: 'SomeStreet', zipCode: '11111' }


{ zipCode: '22222', street: 'AnotherStreet' }


then query like:

db.collection.update({_id: ObjectId('123')}, {$pullAll: {addresses: [

{ zipCode: '11111', street: 'SomeStreet' }


would fail, because the order of keys ('zipCode', 'street') is different from the one stored in mongo ('street', 'zipCode'). More can be found here http://jira.mongodb.org/browse/SERVER-1914

Therefore, we need to force the order on every insert and update for consistency.

Comment by Jonathan H. Wage [ 24/Nov/10 ]

This is not a problem anymore after the recent refactoring!

Generated at Tue Nov 24 17:12:40 EST 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.