summaryrefslogtreecommitdiff
path: root/jstests/basic9.js
blob: b8308fba7d08c74e5edf9a79ebbda6feaf82f8ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// 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))
    t.save(param);
    // Should not get here.
    printjson(db.getLastErrorObj());
}

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");