// protected methods /// <inheritdoc /> protected override BsonDocument CreateCommand(ICoreSessionHandle session, ConnectionDescription connectionDescription, int attempt, long?transactionNumber) { var serverVersion = connectionDescription.ServerVersion; if (!Feature.Collation.IsSupported(serverVersion)) { if (_updates.Items.Skip(_updates.Offset).Take(_updates.Count).Any(u => u.Collation != null)) { throw new NotSupportedException($"Server version {serverVersion} does not support collations."); } } if (!Feature.ArrayFilters.IsSupported(serverVersion)) { if (_updates.Items.Skip(_updates.Offset).Take(_updates.Count).Any(u => u.ArrayFilters != null)) { throw new NotSupportedException($"Server version {serverVersion} does not support arrayFilters."); } } var writeConcern = WriteConcernHelper.GetWriteConcernForWriteCommand(session, WriteConcern); return(new BsonDocument { { "update", _collectionNamespace.CollectionName }, { "ordered", IsOrdered }, { "bypassDocumentValidation", () => _bypassDocumentValidation.Value, _bypassDocumentValidation.HasValue }, { "writeConcern", writeConcern, writeConcern != null }, { "txnNumber", () => transactionNumber.Value, transactionNumber.HasValue } }); }
// protected methods /// <inheritdoc /> protected override BsonDocument CreateCommand(ICoreSessionHandle session, ConnectionDescription connectionDescription, int attempt, long?transactionNumber) { var serverVersion = connectionDescription.ServerVersion; if (!Feature.Collation.IsSupported(serverVersion)) { if (_deletes.Items.Skip(_deletes.Offset).Take(_deletes.Count).Any(d => d.Collation != null)) { throw new NotSupportedException($"Server version {serverVersion} does not support collations."); } } if (Feature.HintForDeleteOperations.DriverMustThrowIfNotSupported(serverVersion) || (WriteConcern != null && !WriteConcern.IsAcknowledged)) { if (_deletes.Items.Skip(_deletes.Offset).Take(_deletes.Count).Any(u => u.Hint != null)) { throw new NotSupportedException($"Server version {serverVersion} does not support hints."); } } var writeConcern = WriteConcernHelper.GetWriteConcernForWriteCommand(session, WriteConcern); return(new BsonDocument { { "delete", _collectionNamespace.CollectionName }, { "ordered", IsOrdered }, { "writeConcern", writeConcern, writeConcern != null }, { "txnNumber", () => transactionNumber.Value, transactionNumber.HasValue } }); }
public void GetWriteConcernForWriteCommand_should_return_expected_result( bool isInTransaction, string writeConcernJson, string expectedResult) { var session = CreateSession(isInTransaction: isInTransaction); var writeConcern = writeConcernJson == null ? null : WriteConcern.FromBsonDocument(BsonDocument.Parse(writeConcernJson)); var result = WriteConcernHelper.GetWriteConcernForWriteCommand(session, writeConcern); result.Should().Be(expectedResult); }
// protected methods /// <inheritdoc /> protected override BsonDocument CreateCommand(ICoreSessionHandle session, ConnectionDescription connectionDescription, int attempt, long?transactionNumber) { var writeConcern = WriteConcernHelper.GetWriteConcernForWriteCommand(session, WriteConcern); return(new BsonDocument { { "insert", _collectionNamespace.CollectionName }, { "ordered", IsOrdered }, { "bypassDocumentValidation", () => _bypassDocumentValidation, _bypassDocumentValidation.HasValue }, { "writeConcern", writeConcern, writeConcern != null }, { "txnNumber", () => transactionNumber.Value, transactionNumber.HasValue } }); }