(function() {
|
"use strict";
|
|
const st = new ShardingTest({shards: 2, config: 1});
|
const dbName = "testDb";
|
|
const collName = "testColl";
|
const ns = dbName + "." + collName;
|
const db = st.getDB(dbName);
|
|
// Set up a sharded collection with two shards and a chunk on each.
|
assert.commandWorked(st.s.adminCommand({enableSharding: dbName}));
|
assert.commandWorked(st.s.adminCommand({shardCollection: ns, key: {skey: 1}}));
|
assert.commandWorked(st.s.adminCommand({split: ns, middle: {skey: 0}}));
|
assert.commandWorked(
|
st.s.adminCommand({moveChunk: ns, find: {skey: MinKey}, to: st.shard0.shardName}));
|
assert.commandWorked(st.s.adminCommand({moveChunk: ns, find: {skey: 1}, to: st.shard1.shardName}));
|
|
// Inserting with a dollar prefixed field works.
|
assert.commandWorked(db.runCommand({
|
insert: collName,
|
documents: [{skey: -1, dollarPrefixedField: {"$date": "2012-02-29T00:00:00Z"}}]
|
}));
|
|
// But an update that uses a transaction to move the document across shards fails with: "unknown
|
// operator: $date"
|
assert.commandWorked(db.runCommand({
|
update: collName,
|
updates: [{q: {skey: -1}, u: {"$set": {skey: 1}}, upsert: false}],
|
txnNumber: NumberLong(1),
|
lsid: {id: UUID()},
|
}));
|
|
st.stop();
|
})();
|