Added support for bypassDocumentValidation · pkdevbox/mongo-java-driver@d36fef6 · GitHub
Skip to content

Commit d36fef6

Browse files
committed
Added support for bypassDocumentValidation
JAVA-1985
1 parent 19bdb9d commit d36fef6

57 files changed

Lines changed: 1823 additions & 385 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

driver-async/build.gradle

Lines changed: 1 addition & 1 deletion

driver-async/src/main/com/mongodb/async/client/AggregateIterable.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,17 @@ public interface AggregateIterable<TResult> extends MongoIterable<TResult> {
7474
* @mongodb.driver.manual reference/method/cursor.batchSize/#cursor.batchSize Batch Size
7575
*/
7676
AggregateIterable<TResult> batchSize(int batchSize);
77+
78+
/**
79+
* Sets the bypass document level validation flag.
80+
*
81+
* <p>Note: This only applies when an $out stage is specified</p>.
82+
*
83+
* @param bypassDocumentValidation If true, allows the write to opt-out of document level validation.
84+
* @return this
85+
* @since 3.2
86+
* @mongodb.driver.manual reference/command/aggregate/ Aggregation
87+
* @mongodb.server.release 3.2
88+
*/
89+
AggregateIterable<TResult> bypassDocumentValidation(Boolean bypassDocumentValidation);
7790
}

driver-async/src/main/com/mongodb/async/client/AggregateIterableImpl.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class AggregateIterableImpl<TDocument, TResult> implements AggregateIterable<TRe
5454
private Integer batchSize;
5555
private long maxTimeMS;
5656
private Boolean useCursor;
57+
private Boolean bypassDocumentValidation;
5758

5859
AggregateIterableImpl(final MongoNamespace namespace, final Class<TDocument> documentClass, final Class<TResult> resultClass,
5960
final CodecRegistry codecRegistry, final ReadPreference readPreference, final AsyncOperationExecutor executor,
@@ -131,14 +132,21 @@ public void batchCursor(final SingleResultCallback<AsyncBatchCursor<TResult>> ca
131132
execute().batchCursor(callback);
132133
}
133134

135+
@Override
136+
public AggregateIterable<TResult> bypassDocumentValidation(final Boolean bypassDocumentValidation) {
137+
this.bypassDocumentValidation = bypassDocumentValidation;
138+
return this;
139+
}
140+
134141
private MongoIterable<TResult> execute() {
135142
List<BsonDocument> aggregateList = createBsonDocumentList();
136143
BsonValue outCollection = getAggregateOutCollection(aggregateList);
137144

138145
if (outCollection != null) {
139146
AggregateToCollectionOperation operation = new AggregateToCollectionOperation(namespace, aggregateList)
140147
.maxTime(maxTimeMS, MILLISECONDS)
141-
.allowDiskUse(allowDiskUse);
148+
.allowDiskUse(allowDiskUse)
149+
.bypassDocumentValidation(bypassDocumentValidation);
142150
MongoIterable<TResult> delegated = new FindIterableImpl<TDocument, TResult>(new MongoNamespace(namespace.getDatabaseName(),
143151
outCollection.asString().getValue()),
144152
documentClass, resultClass, codecRegistry, primary(), executor, new BsonDocument(),

driver-async/src/main/com/mongodb/async/client/MongoCollection.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.mongodb.client.model.IndexModel;
3131
import com.mongodb.client.model.IndexOptions;
3232
import com.mongodb.client.model.InsertManyOptions;
33+
import com.mongodb.client.model.InsertOneOptions;
3334
import com.mongodb.client.model.RenameCollectionOptions;
3435
import com.mongodb.client.model.UpdateOptions;
3536
import com.mongodb.client.model.WriteModel;
@@ -285,6 +286,20 @@ void bulkWrite(List<? extends WriteModel<? extends TDocument>> requests, BulkWri
285286
*/
286287
void insertOne(TDocument document, SingleResultCallback<Void> callback);
287288

289+
/**
290+
* Inserts the provided document. If the document is missing an identifier, the driver should generate one.
291+
*
292+
* @param document the document to insert
293+
* @param options the options to apply to the operation
294+
* @param callback the callback that is completed once the insert has completed
295+
* @throws com.mongodb.MongoWriteException returned via the callback
296+
* @throws com.mongodb.MongoWriteConcernException returned via the callback
297+
* @throws com.mongodb.MongoCommandException returned via the callback
298+
* @throws com.mongodb.MongoException returned via the callback
299+
* @since 3.2
300+
*/
301+
void insertOne(TDocument document, InsertOneOptions options, SingleResultCallback<Void> callback);
302+
288303
/**
289304
* Inserts one or more documents. A call to this method is equivalent to a call to the {@code bulkWrite} method
290305
*

driver-async/src/main/com/mongodb/async/client/MongoCollectionImpl.java

Lines changed: 58 additions & 43 deletions

0 commit comments

Comments
 (0)