$set fails to create nested keys if supplied with a non existent topmost key #148

Closed
liuaiping opened this Issue Jun 14, 2015 · 4 comments

Comments

Projects
None yet
4 participants
@liuaiping

The follow codes:
ejdb>db.aipi.update({"$set":{"info.name.par.age":40, "info.name.mot.age":40}})
But the result was:
>{info: { name: { mot: { age: 40 } } } }

The "par" was not created. Why ?

Second, i want to update the age to 50, like this:
ejdb> db.aipi.update({"$set":{"info.name.mot.age":56}})
the result was : Segmentation fault (core dumped)

If i used the c interface and the result was i couldn't operate the "info.name.mot" anymore.

@elendilm

This comment has been minimized.

Show comment
Hide comment
@elendilm

elendilm Jun 15, 2015

I just tested this and can confirm that it is a bug.

If there is no key named 'a' then

the bug OCCURS in {"$set":{"a.b.c.d":50, "a.f.g.h":50}}
but DOES NOT occur when updated with {"$set":{"a.b.c.d":50, "e.f.g.h":50}}

If there is a topmost key named 'a': { } then

The bug no longer occurs when updated with {"$set":{"a.b.c.d":50, "a.f.g.h":50}}.

So I think it may have something to do with the topmost non existent key.

I just tested this and can confirm that it is a bug.

If there is no key named 'a' then

the bug OCCURS in {"$set":{"a.b.c.d":50, "a.f.g.h":50}}
but DOES NOT occur when updated with {"$set":{"a.b.c.d":50, "e.f.g.h":50}}

If there is a topmost key named 'a': { } then

The bug no longer occurs when updated with {"$set":{"a.b.c.d":50, "a.f.g.h":50}}.

So I think it may have something to do with the topmost non existent key.

@elendilm

This comment has been minimized.

Show comment
Hide comment
@elendilm

elendilm Jun 15, 2015

Could you change the title to something like "$set fails to create nested keys if supplied with a non existent topmost key" or something like that.

Could you change the title to something like "$set fails to create nested keys if supplied with a non existent topmost key" or something like that.

@liuaiping

This comment has been minimized.

Show comment
Hide comment

@elendilm Thanks,Sure.

@liuaiping liuaiping changed the title from Specify multiple field-value pairs, $set only create one field-vale to $set fails to create nested keys if supplied with a non existent topmost key Jun 15, 2015

@adamansky

This comment has been minimized.

Show comment
Hide comment
@adamansky

adamansky Jun 15, 2015

Member

Thank you very much! Hope will fix it shortly.

Member

adamansky commented Jun 15, 2015

Thank you very much! Hope will fix it shortly.

tyutyunkov added a commit that referenced this issue Jul 13, 2015

tyutyunkov added a commit that referenced this issue Jul 13, 2015

tyutyunkov added a commit that referenced this issue Jul 13, 2015

tyutyunkov added a commit that referenced this issue Jul 13, 2015

@adamansky adamansky closed this Jul 24, 2015

markusmarx added a commit to markusmarx/ejdb that referenced this issue Aug 1, 2015

Merge tag 'v1.2.10'
  * Fix: Uninitialized Memory Conditional fixe #155
  * Fix: $set fails to create nested keys if supplied with a non existent topmost key #148
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment