[SERVER-1988] Upsert allows inserting records with dots in key names Created: 22/Oct/10 Updated: 12/Jul/16 Resolved: 17/Dec/10 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 1.6.2 |
| Fix Version/s: | 1.7.4 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Andrew Bayliss | Assignee: | Antoine Girbal |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
linux 32 bit |
||
| Operating System: | Linux |
| Participants: |
| Description |
|
Insert does not allow inserting records with fields containing keys with dots in them, which as I understand it is the correct behaviour. An upsert however, will perfectly happily do this: > db.test.insert( { "test": 1, "te.st": 1 }); , { "test": 1, "te.st": 1 }, 1); |
| Comments |
| Comment by auto [ 17/Dec/10 ] |
|
Author: {u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}Message: |
| Comment by Antoine Girbal [ 17/Dec/10 ] |
|
did following tests on patch > db.dot.insert( {"a": 0,"b": 1}) ) , {"b.b": 1}) > db.dot.update( {"a": 0}, {$set: { "c.c": 1}}) } , {"": { "c.c": 1}}) , {}) |
| Comment by auto [ 17/Dec/10 ] |
|
Author: {u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}Message: |
| Comment by Eliot Horowitz (Inactive) [ 17/Dec/10 ] |
|
That sounds right. |
| Comment by Antoine Girbal [ 17/Dec/10 ] |
|
Ok so as agreed, the fix goes into the shell, not db since it does not inspect full obj.
|
| Comment by Eliot Horowitz (Inactive) [ 14/Dec/10 ] |
|
We only have to inspect the update spec, not the resulting object. Can probably rename and reuse checkNoMods, but its been a while |
| Comment by Antoine Girbal [ 13/Dec/10 ] |
|
it looks to me that we do not run a complete parse of the update object at any point of the processing. |
| Comment by Eliot Horowitz (Inactive) [ 13/Dec/10 ] |
|
For update it does have some protection in update.cpp |
| Comment by Antoine Girbal [ 13/Dec/10 ] |
|
basically mongodb does not reject key names with ".", it's at the driver's discretion. |