Skip to content

Replace top-level zero timestamp with current timestamp for consistency and implement bypassEmptyTsReplacement parameter #205

@AlekSi

Description

@AlekSi

Describe the bug

Inserting a zero timestamp value (Timestamp(0, 0)) as a top-level document field should insert a non-zero timestamp based on the current time, like in MongoDB.

Reproduction Steps

const coll = db.test;

coll.drop();

const doc = {
  _id: "id",
  v: Timestamp(0, 0),
  d: {
    dv: Timestamp(0, 0),
  }
}

coll.insert(doc);

const actual = coll.find({}).toArray()[0];
assert.eq("id", actual._id);

const now = Date.now() / 1000;

assert.neq(Timestamp(0, 0), actual.v);
assert.neq(0, actual.v.i);
assert.between(now - 5, actual.v.t, now + 5);

assert.eq(Timestamp(0, 0), actual.d.dv);
assert.eq(0, actual.d.dv.i);

See FerretDB/FerretDB#5200 and FerretDB/FerretDB#5199.

Expected behavior

Test passes.

Actual behavior

DocumentDB inserts both timestamps as Timestamp(0, 0). Test fails.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions