2013-11-14 09:13:38 -05:00
|
|
|
// Tests that $<prefix> field names are not allowed, but you can use a $ anywhere else.
|
2010-08-23 12:54:02 -04:00
|
|
|
t = db.getCollection( "foo_basic9" );
|
2013-11-14 09:13:38 -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) {
|
|
|
|
|
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));
|
2009-07-21 15:08:45 -04:00
|
|
|
}
|
|
|
|
|
|
2013-11-14 09:13:38 -05:00
|
|
|
t.save({foo$foo:5});
|
|
|
|
|
t.save({foo$:5});
|
2009-07-21 15:08:45 -04:00
|
|
|
|
2013-11-14 09:13:38 -05:00
|
|
|
assert.throws(doBadSave, [{$foo:5}], "key names aren't allowed to start with $ doesn't work");
|
|
|
|
|
assert.throws(doBadSave,
|
|
|
|
|
[{x:{$foo:5}}],
|
|
|
|
|
"embedded key names aren't allowed to start with $ doesn't work");
|