SinceDeprecatedCmd

Undocumented in source.

Members

Variables

maxAwaitTimeMS
Nullable!long maxAwaitTimeMS;
Undocumented in source.
maxScan
Nullable!long maxScan;
Undocumented in source.

Examples

@since nullifies field when server version is below minimum

SinceUntilCmd cmd;
cmd.a = 1;
cmd.b = 2;

auto test = cmd;
enforceWireVersionConstraints(test, WireVersion.v30);
assert(test.a.isNull);
assert(!test.b.isNull);

@until nullifies field when server version exceeds maximum

SinceUntilCmd cmd;
cmd.a = 1;
cmd.b = 2;

auto test = cmd;
enforceWireVersionConstraints(test, WireVersion.v32);
assert(test.a.isNull);
assert(test.b.isNull);

@since preserves field when server version meets minimum

SinceUntilCmd cmd;
cmd.a = 1;
cmd.b = 2;

auto test = cmd;
enforceWireVersionConstraints(test, WireVersion.v34);
assert(!test.a.isNull);
assert(test.b.isNull);

@errorBefore throws when field is set and server version is below threshold

ErrorBeforeCmd cmd;
cmd.field = 42;
try {
	enforceWireVersionConstraints(cmd, WireVersion.v40);
	assert(false, "Should have thrown");
} catch (MongoException e) {
	// expected
}

@errorBefore does not throw when field is set and server version is at threshold

ErrorBeforeCmd cmd;
cmd.field = 42;
enforceWireVersionConstraints(cmd, WireVersion.v44);
assert(!cmd.field.isNull);

@errorBefore does not throw when field is set and server version is above threshold

ErrorBeforeCmd cmd;
cmd.field = 42;
enforceWireVersionConstraints(cmd, WireVersion.v60);
assert(!cmd.field.isNull);

@errorBefore does not throw when field is not set

ErrorBeforeCmd cmd;
enforceWireVersionConstraints(cmd, WireVersion.v30);
assert(cmd.field.isNull);

@deprecatedSince preserves field and only logs at deprecated version

DeprecatedCmd cmd;
cmd.oldField = 10;
enforceWireVersionConstraints(cmd, WireVersion.v40);
assert(!cmd.oldField.isNull);
assert(cmd.oldField.get == 10);

@deprecatedSince preserves field above deprecated version

DeprecatedCmd cmd;
cmd.oldField = 10;
enforceWireVersionConstraints(cmd, WireVersion.v60);
assert(!cmd.oldField.isNull);

@deprecatedSince preserves field below deprecated version without warning

DeprecatedCmd cmd;
cmd.oldField = 10;
enforceWireVersionConstraints(cmd, WireVersion.v36);
assert(!cmd.oldField.isNull);

@deprecatedSince does nothing when field is not set

DeprecatedCmd cmd;
enforceWireVersionConstraints(cmd, WireVersion.v60);
assert(cmd.oldField.isNull);

Combined UDAs: @errorBefore throws while @since and @deprecatedSince still apply

CombinedCmd cmd;
cmd.allowDiskUse = true;
cmd.maxAwaitTimeMS = 5000;
cmd.maxScan = 100;

auto t1 = cmd;
try {
	enforceWireVersionConstraints(t1, WireVersion.v30);
	assert(false, "Should have thrown due to errorBefore(v44)");
} catch (MongoException e) {
	// expected
}

Combined UDAs: all fields valid at v44, @deprecatedSince only logs

CombinedCmd cmd;
cmd.allowDiskUse = true;
cmd.maxAwaitTimeMS = 5000;
cmd.maxScan = 100;

enforceWireVersionConstraints(cmd, WireVersion.v44);
assert(!cmd.allowDiskUse.isNull);
assert(!cmd.maxAwaitTimeMS.isNull);
assert(!cmd.maxScan.isNull);

Combined UDAs: @since nullifies field below minimum while others are independent

SinceDeprecatedCmd cmd;
cmd.maxAwaitTimeMS = 5000;
cmd.maxScan = 100;

enforceWireVersionConstraints(cmd, WireVersion.v30);
assert(cmd.maxAwaitTimeMS.isNull);
assert(!cmd.maxScan.isNull);

Combined UDAs: @since preserves field at sufficient version

SinceDeprecatedCmd cmd;
cmd.maxAwaitTimeMS = 5000;
cmd.maxScan = 100;

enforceWireVersionConstraints(cmd, WireVersion.v34);
assert(!cmd.maxAwaitTimeMS.isNull);
assert(!cmd.maxScan.isNull);

Meta