Skip to content

MIM: Incorrect positional $ behavior sometimes #26

@brondsem

Description

@brondsem

While working on the fix of #25, I found that sometimes the wrong behavior occurs. On branch mim_dot_dollar_wrong this is illustrated by test_inc_dotted_dollar_middle2 with a $ in the middle of dotted field notation, and selecting for the 2nd subdoc in the list:

Ming/ming/tests/test_mim.py

Lines 213 to 217 in 256f2b1

def test_inc_dotted_dollar_middle2(self):
# match on g=2 and $inc by 10
self.coll.update({'b.f.g': 2}, { '$inc': { 'b.f.$.g': 10 } })
obj = self.coll.find_one({}, { '_id': 0, 'b.f': 1 })
self.assertEqual(obj, { 'b': { 'f': [ { 'g': 1 }, { 'g': 12 } ] }})

AssertionError: {'b': {'f': [{'g': 11}, {'g': 2}]}} != {'b': {'f': [{'g': 1}, {'g': 12}]}}
- {'b': {'f': [{'g': 11}, {'g': 2}]}}
?                    -

+ {'b': {'f': [{'g': 1}, {'g': 12}]}}
?

That branch has expanded tests where the $ is at the end of dotted field notation, and they do all pass.

I haven't looked into this any further, seems kinda tricky. And not actually a blocking problem for me right now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions