Skip to content

Commit a63ab4d

Browse files
Revert "Handled dollar prefixed values for "createOrReplace" Mongo implementa…" (#213)
This reverts commit 9aa8fe6.
1 parent 9b4eb6e commit a63ab4d

File tree

3 files changed

+4
-26
lines changed

3 files changed

+4
-26
lines changed

document-store/src/integrationTest/resources/create/document_one.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
{
99
"name": "Mars",
10-
"color": "$Red",
10+
"color": "Red",
1111
"humans_live": "possibly in future",
1212
"tags": {}
1313
}

document-store/src/integrationTest/resources/create/document_one_response.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
{
1010
"name": "Mars",
11-
"color": "$Red",
11+
"color": "Red",
1212
"humans_live": "possibly in future",
1313
"tags": {}
1414
}

document-store/src/main/java/org/hypertrace/core/documentstore/mongo/MongoUtils.java

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
import com.fasterxml.jackson.core.JsonProcessingException;
1515
import com.fasterxml.jackson.databind.JsonNode;
1616
import com.fasterxml.jackson.databind.ObjectMapper;
17-
import com.fasterxml.jackson.databind.node.ArrayNode;
1817
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
1918
import com.fasterxml.jackson.databind.node.ObjectNode;
20-
import com.fasterxml.jackson.databind.node.TextNode;
2119
import com.mongodb.BasicDBObject;
2220
import com.mongodb.client.model.ReturnDocument;
2321
import java.io.IOException;
@@ -37,7 +35,6 @@
3735
public final class MongoUtils {
3836
public static final String FIELD_SEPARATOR = ".";
3937
public static final String PREFIX = "$";
40-
private static final String UNICODE_FOR_FIELD_PREFIX = "\\u0024";
4138
private static final String LITERAL = PREFIX + "literal";
4239
private static final String UNSUPPORTED_OPERATION = "No MongoDB support available for: '%s'";
4340
private static final ObjectMapper MAPPER = new ObjectMapper();
@@ -57,19 +54,15 @@ public static String encodeKey(final String key) {
5754
return null;
5855
}
5956

60-
return key.replace("\\", "\\\\")
61-
.replace(PREFIX, UNICODE_FOR_FIELD_PREFIX)
62-
.replace(FIELD_SEPARATOR, "\\u002e");
57+
return key.replace("\\", "\\\\").replace(PREFIX, "\\u0024").replace(FIELD_SEPARATOR, "\\u002e");
6358
}
6459

6560
public static String decodeKey(final String key) {
6661
if (key == null) {
6762
return null;
6863
}
6964

70-
return key.replace("\\u002e", FIELD_SEPARATOR)
71-
.replace(UNICODE_FOR_FIELD_PREFIX, PREFIX)
72-
.replace("\\\\", "\\");
65+
return key.replace("\\u002e", FIELD_SEPARATOR).replace("\\u0024", PREFIX).replace("\\\\", "\\");
7366
}
7467

7568
public static String getLastField(final String fieldPath) {
@@ -106,10 +99,6 @@ public static JsonNode recursiveClone(
10699
JsonNode src,
107100
UnaryOperator<String> function,
108101
final UnaryOperator<ObjectNode> emptyObjectConverter) {
109-
if (src.isTextual()) {
110-
return new TextNode(function.apply(src.asText()));
111-
}
112-
113102
if (!src.isObject()) {
114103
return src;
115104
}
@@ -124,17 +113,6 @@ public static JsonNode recursiveClone(
124113
if (value.isObject()) {
125114
newValue = recursiveClone(value, function, emptyObjectConverter);
126115
}
127-
if (value.isArray()) {
128-
newValue = new ArrayNode(JsonNodeFactory.instance);
129-
for (int i = 0; i < value.size(); i++) {
130-
final JsonNode elementValue =
131-
recursiveClone(value.get(i), function, emptyObjectConverter);
132-
((ArrayNode) newValue).add(elementValue);
133-
}
134-
}
135-
if (newValue.isTextual()) {
136-
newValue = new TextNode(function.apply(newValue.asText()));
137-
}
138116
tgt.set(newFieldName, newValue);
139117
}
140118
return tgt.isEmpty() ? emptyObjectConverter.apply(tgt) : tgt;

0 commit comments

Comments
 (0)