File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed
main/java/org/springframework/data/mongodb/core/query
test/java/org/springframework/data/mongodb/core/query Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -254,7 +254,7 @@ public Update pull(String key, Object value) {
254
254
* @return
255
255
*/
256
256
public Update pullAll (String key , Object [] values ) {
257
- addFieldOperation ("$pullAll" , key , Arrays .copyOf (values , values .length ));
257
+ addMultiFieldOperation ("$pullAll" , key , Arrays .copyOf (values , values .length ));
258
258
return this ;
259
259
}
260
260
@@ -330,9 +330,19 @@ public DBObject getUpdateObject() {
330
330
return new BasicDBObject (modifierOps );
331
331
}
332
332
333
+ /**
334
+ * This method is not called anymore rather override {@link #addMultiFieldOperation(String, String, Object)}.
335
+ *
336
+ * @param operator
337
+ * @param key
338
+ * @param value
339
+ * @deprectaed Use {@link #addMultiFieldOperation(String, String, Object)} instead.
340
+ */
341
+ @ Deprecated
333
342
protected void addFieldOperation (String operator , String key , Object value ) {
334
343
335
344
Assert .hasText (key , "Key/Path for update must not be null or blank." );
345
+
336
346
modifierOps .put (operator , new BasicDBObject (key , value ));
337
347
this .keysToUpdate .add (key );
338
348
}
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2010-2014 the original author or authors.
2
+ * Copyright 2010-2015 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
23
23
24
24
import org .joda .time .DateTime ;
25
25
import org .junit .Test ;
26
+ import org .springframework .data .mongodb .core .DBObjectTestUtils ;
26
27
27
28
import com .mongodb .BasicDBObject ;
28
29
import com .mongodb .BasicDBObjectBuilder ;
30
+ import com .mongodb .DBObject ;
29
31
30
32
/**
31
33
* Test cases for {@link Update}.
@@ -484,4 +486,22 @@ public void getUpdateObjectShouldReturnCorrectRepresentationForBitwiseXor() {
484
486
public void pushShouldThrowExceptionWhenGivenNegativePosition () {
485
487
new Update ().push ("foo" ).atPosition (-1 ).each ("booh" );
486
488
}
489
+
490
+ /**
491
+ * @see DATAMONGO-1346
492
+ */
493
+ @ Test
494
+ public void registersMultiplePullAllClauses () {
495
+
496
+ Update update = new Update ();
497
+ update .pullAll ("field1" , new String [] { "foo" });
498
+ update .pullAll ("field2" , new String [] { "bar" });
499
+
500
+ DBObject updateObject = update .getUpdateObject ();
501
+
502
+ DBObject pullAll = DBObjectTestUtils .getAsDBObject (updateObject , "$pullAll" );
503
+
504
+ assertThat (pullAll .get ("field1" ), is (notNullValue ()));
505
+ assertThat (pullAll .get ("field2" ), is (notNullValue ()));
506
+ }
487
507
}
You can’t perform that action at this time.
0 commit comments