Skip to content

Commit 15f0181

Browse files
committed
Revert "added keepNull & mergeObjects parameters for insert-update document"
This reverts commit b007c94
1 parent 599fdd3 commit 15f0181

File tree

3 files changed

+8
-100
lines changed

3 files changed

+8
-100
lines changed

src/main/java/com/arangodb/internal/InternalArangoCollection.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,8 @@ protected <T> Request insertDocumentRequest(final T value, final DocumentCreateO
8888
request.putQueryParam(SILENT, params.getSilent());
8989
request.putQueryParam(OVERWRITE, params.getOverwrite());
9090
request.putQueryParam(OVERWRITE_MODE, params.getOverwriteMode() != null ? params.getOverwriteMode().getValue() : null);
91-
request.putQueryParam(ArangoRequestParam.KEEP_NULL, params.getKeepNull());
92-
request.putQueryParam(MERGE_OBJECTS, params.getMergeObjects());
9391
request.putHeaderParam(TRANSACTION_ID, params.getStreamTransactionId());
94-
95-
boolean serializeNullValues = OverwriteMode.update.equals(params.getOverwriteMode());
96-
request.setBody(util(Serializer.CUSTOM).serialize(value, new ArangoSerializer.Options().serializeNullValues(serializeNullValues)));
97-
92+
request.setBody(util(Serializer.CUSTOM).serialize(value));
9893
return request;
9994
}
10095

@@ -130,13 +125,9 @@ protected <T> Request insertDocumentsRequest(final Collection<T> values, final D
130125
request.putQueryParam(SILENT, params.getSilent());
131126
request.putQueryParam(OVERWRITE, params.getOverwrite());
132127
request.putQueryParam(OVERWRITE_MODE, params.getOverwriteMode() != null ? params.getOverwriteMode().getValue() : null);
133-
request.putQueryParam(ArangoRequestParam.KEEP_NULL, params.getKeepNull());
134-
request.putQueryParam(MERGE_OBJECTS, params.getMergeObjects());
135128
request.putHeaderParam(TRANSACTION_ID, params.getStreamTransactionId());
136-
137-
boolean serializeNullValues = OverwriteMode.update.equals(params.getOverwriteMode());
138-
request.setBody(util(Serializer.CUSTOM).serialize(values, new ArangoSerializer.Options()
139-
.serializeNullValues(serializeNullValues).stringAsJson(true)));
129+
request.setBody(util(Serializer.CUSTOM)
130+
.serialize(values, new ArangoSerializer.Options().serializeNullValues(false).stringAsJson(true)));
140131
return request;
141132
}
142133

src/main/java/com/arangodb/model/DocumentCreateOptions.java

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ public class DocumentCreateOptions {
3535
private OverwriteMode overwriteMode;
3636
private Boolean silent;
3737
private String streamTransactionId;
38-
private Boolean keepNull;
39-
private Boolean mergeObjects;
40-
4138

4239
public DocumentCreateOptions() {
4340
super();
@@ -144,38 +141,4 @@ public DocumentCreateOptions streamTransactionId(final String streamTransactionI
144141
return this;
145142
}
146143

147-
public Boolean getKeepNull() {
148-
return keepNull;
149-
}
150-
151-
/**
152-
* @param keepNull If the intention is to delete existing attributes with the patch command, the URL query parameter
153-
* keepNull can be used with a value of false. This will modify the behavior of the patch command to
154-
* remove any attributes from the existing document that are contained in the patch document with an
155-
* attribute value of null.
156-
* @return options
157-
* @apiNote only considered if {@link this#overwriteMode} is set to {@link OverwriteMode#update}
158-
* @apiNote the document key field must be not null
159-
*/
160-
public DocumentCreateOptions keepNull(Boolean keepNull) {
161-
this.keepNull = keepNull;
162-
return this;
163-
}
164-
165-
public Boolean getMergeObjects() {
166-
return mergeObjects;
167-
}
168-
169-
/**
170-
* @param mergeObjects Controls whether objects (not arrays) will be merged if present in both the existing and the patch
171-
* document. If set to false, the value in the patch document will overwrite the existing document's
172-
* value. If set to true, objects will be merged. The default is true.
173-
* @return options
174-
* @apiNote only considered if {@link this#overwriteMode} is set to {@link OverwriteMode#update}
175-
*/
176-
public DocumentCreateOptions mergeObjects(Boolean mergeObjects) {
177-
this.mergeObjects = mergeObjects;
178-
return this;
179-
}
180-
181144
}

src/test/java/com/arangodb/ArangoCollectionTest.java

Lines changed: 5 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -224,59 +224,13 @@ public void insertDocumentOverwriteModeUpdate() {
224224
final DocumentCreateEntity<BaseDocument> meta = collection.insertDocument(doc);
225225

226226
doc.addAttribute("bar", "b");
227-
final DocumentCreateEntity<BaseDocument> updated = collection
227+
final DocumentCreateEntity<BaseDocument> upsert = collection
228228
.insertDocument(doc, new DocumentCreateOptions().overwriteMode(OverwriteMode.update).returnNew(true));
229229

230-
assertThat(updated, is(notNullValue()));
231-
assertThat(updated.getRev(), is(not(meta.getRev())));
232-
assertThat(updated.getNew().getAttribute("foo").toString(), is("a"));
233-
assertThat(updated.getNew().getAttribute("bar").toString(), is("b"));
234-
}
235-
236-
@Test
237-
public void insertDocumentOverwriteModeUpdateKeepNullTrue() {
238-
assumeTrue(isAtLeastVersion(3, 7));
239-
240-
final BaseDocument initialDoc = new BaseDocument();
241-
initialDoc.addAttribute("foo", "a");
242-
final DocumentCreateEntity<BaseDocument> meta = collection.insertDocument(initialDoc);
243-
244-
final BaseDocument updatedDoc = new BaseDocument(initialDoc.getKey());
245-
updatedDoc.addAttribute("foo", null);
246-
updatedDoc.addAttribute("bar", "b");
247-
final DocumentCreateEntity<BaseDocument> updated = collection
248-
.insertDocument(updatedDoc, new DocumentCreateOptions()
249-
.overwriteMode(OverwriteMode.update)
250-
.keepNull(true)
251-
.returnNew(true));
252-
253-
assertThat(updated, is(notNullValue()));
254-
assertThat(updated.getRev(), is(not(meta.getRev())));
255-
assertThat(updated.getNew().getProperties().containsKey("foo"), is(true));
256-
assertThat(updated.getNew().getAttribute("foo"), is(nullValue()));
257-
assertThat(updated.getNew().getAttribute("bar").toString(), is("b"));
258-
}
259-
260-
@Test
261-
public void insertDocumentOverwriteModeUpdateMergeObjectsFalse() {
262-
assumeTrue(isAtLeastVersion(3, 7));
263-
264-
final BaseDocument doc = new BaseDocument();
265-
Map<String, String> fieldA = Collections.singletonMap("a", "a");
266-
doc.addAttribute("foo", fieldA);
267-
final DocumentCreateEntity<BaseDocument> meta = collection.insertDocument(doc);
268-
269-
Map<String, String> fieldB = Collections.singletonMap("b", "b");
270-
doc.addAttribute("foo", fieldB);
271-
final DocumentCreateEntity<BaseDocument> updated = collection
272-
.insertDocument(doc, new DocumentCreateOptions()
273-
.overwriteMode(OverwriteMode.update)
274-
.mergeObjects(false)
275-
.returnNew(true));
276-
277-
assertThat(updated, is(notNullValue()));
278-
assertThat(updated.getRev(), is(not(meta.getRev())));
279-
assertThat(updated.getNew().getAttribute("foo"), is(fieldB));
230+
assertThat(upsert, is(notNullValue()));
231+
assertThat(upsert.getRev(), is(not(meta.getRev())));
232+
assertThat(upsert.getNew().getAttribute("foo").toString(), is("a"));
233+
assertThat(upsert.getNew().getAttribute("bar").toString(), is("b"));
280234
}
281235

282236
@Test

0 commit comments

Comments
 (0)