Files
mongo/jstests/core/basic9.js

20 lines
651 B
JavaScript
Raw Normal View History

2013-11-14 09:13:38 -05:00
// Tests that $<prefix> field names are not allowed, but you can use a $ anywhere else.
t = db.getCollection( "foo_basic9" );
2013-11-14 09:13:38 -05:00
t.drop()
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))
var res = t.save(param);
2013-11-14 09:13:38 -05:00
// Should not get here.
print('Should have errored out: ' + tojson(res));
}
2013-11-14 09:13:38 -05:00
t.save({foo$foo:5});
t.save({foo$:5});
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");