Files
mongo/jstests/core/basic9.js
Randolph Tan 5595b94560 SERVER-12127 migrate js tests to jscore suite when not related to writes
Moved test jstest/[a-i].js -> jstests/core/ and made changes to comply with write command api
2014-02-28 16:26:33 -05:00

20 lines
651 B
JavaScript

// Tests that $<prefix> field names are not allowed, but you can use a $ anywhere else.
t = db.getCollection( "foo_basic9" );
t.drop()
// more diagnostics on bad save, if exception fails
doBadSave = function(param) {
print("doing save with " + tojson(param))
var res = t.save(param);
// Should not get here.
print('Should have errored out: ' + tojson(res));
}
t.save({foo$foo:5});
t.save({foo$:5});
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");