2013-11-14 09:13:38 -05:00
|
|
|
// Tests that $<prefix> field names are not allowed, but you can use a $ anywhere else.
|
2016-03-09 12:17:50 -05:00
|
|
|
t = db.getCollection("foo_basic9");
|
2016-02-04 12:29:01 -05:00
|
|
|
t.drop();
|
2009-07-21 15:08:45 -04:00
|
|
|
|
2013-11-14 09:13:38 -05:00
|
|
|
// more diagnostics on bad save, if exception fails
|
|
|
|
|
doBadSave = function(param) {
|
2016-02-04 12:29:01 -05:00
|
|
|
print("doing save with " + tojson(param));
|
2014-01-14 14:09:42 -05:00
|
|
|
var res = t.save(param);
|
2013-11-14 09:13:38 -05:00
|
|
|
// Should not get here.
|
2014-01-14 14:09:42 -05:00
|
|
|
print('Should have errored out: ' + tojson(res));
|
2016-02-04 12:29:01 -05:00
|
|
|
};
|
2009-07-21 15:08:45 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
t.save({foo$foo: 5});
|
|
|
|
|
t.save({foo$: 5});
|
2009-07-21 15:08:45 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.throws(doBadSave, [{$foo: 5}], "key names aren't allowed to start with $ doesn't work");
|
2016-05-28 17:55:12 -04:00
|
|
|
assert.throws(
|
|
|
|
|
doBadSave, [{x: {$foo: 5}}], "embedded key names aren't allowed to start with $ doesn't work");
|