diff --git a/document-store/src/integrationTest/resources/create/document_one.json b/document-store/src/integrationTest/resources/create/document_one.json index b6b67659..a43f7f1b 100644 --- a/document-store/src/integrationTest/resources/create/document_one.json +++ b/document-store/src/integrationTest/resources/create/document_one.json @@ -7,7 +7,7 @@ }, { "name": "Mars", - "color": "$Red", + "color": "Red", "humans_live": "possibly in future", "tags": {} } diff --git a/document-store/src/integrationTest/resources/create/document_one_response.json b/document-store/src/integrationTest/resources/create/document_one_response.json index 1745462e..ac03b697 100644 --- a/document-store/src/integrationTest/resources/create/document_one_response.json +++ b/document-store/src/integrationTest/resources/create/document_one_response.json @@ -8,7 +8,7 @@ }, { "name": "Mars", - "color": "$Red", + "color": "Red", "humans_live": "possibly in future", "tags": {} } diff --git a/document-store/src/main/java/org/hypertrace/core/documentstore/mongo/MongoUtils.java b/document-store/src/main/java/org/hypertrace/core/documentstore/mongo/MongoUtils.java index 3be86415..6efb08d9 100644 --- a/document-store/src/main/java/org/hypertrace/core/documentstore/mongo/MongoUtils.java +++ b/document-store/src/main/java/org/hypertrace/core/documentstore/mongo/MongoUtils.java @@ -14,10 +14,8 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.fasterxml.jackson.databind.node.TextNode; import com.mongodb.BasicDBObject; import com.mongodb.client.model.ReturnDocument; import java.io.IOException; @@ -37,7 +35,6 @@ public final class MongoUtils { public static final String FIELD_SEPARATOR = "."; public static final String PREFIX = "$"; - private static final String UNICODE_FOR_FIELD_PREFIX = "\\u0024"; private static final String LITERAL = PREFIX + "literal"; private static final String UNSUPPORTED_OPERATION = "No MongoDB support available for: '%s'"; private static final ObjectMapper MAPPER = new ObjectMapper(); @@ -57,9 +54,7 @@ public static String encodeKey(final String key) { return null; } - return key.replace("\\", "\\\\") - .replace(PREFIX, UNICODE_FOR_FIELD_PREFIX) - .replace(FIELD_SEPARATOR, "\\u002e"); + return key.replace("\\", "\\\\").replace(PREFIX, "\\u0024").replace(FIELD_SEPARATOR, "\\u002e"); } public static String decodeKey(final String key) { @@ -67,9 +62,7 @@ public static String decodeKey(final String key) { return null; } - return key.replace("\\u002e", FIELD_SEPARATOR) - .replace(UNICODE_FOR_FIELD_PREFIX, PREFIX) - .replace("\\\\", "\\"); + return key.replace("\\u002e", FIELD_SEPARATOR).replace("\\u0024", PREFIX).replace("\\\\", "\\"); } public static String getLastField(final String fieldPath) { @@ -106,10 +99,6 @@ public static JsonNode recursiveClone( JsonNode src, UnaryOperator function, final UnaryOperator emptyObjectConverter) { - if (src.isTextual()) { - return new TextNode(function.apply(src.asText())); - } - if (!src.isObject()) { return src; } @@ -124,17 +113,6 @@ public static JsonNode recursiveClone( if (value.isObject()) { newValue = recursiveClone(value, function, emptyObjectConverter); } - if (value.isArray()) { - newValue = new ArrayNode(JsonNodeFactory.instance); - for (int i = 0; i < value.size(); i++) { - final JsonNode elementValue = - recursiveClone(value.get(i), function, emptyObjectConverter); - ((ArrayNode) newValue).add(elementValue); - } - } - if (newValue.isTextual()) { - newValue = new TextNode(function.apply(newValue.asText())); - } tgt.set(newFieldName, newValue); } return tgt.isEmpty() ? emptyObjectConverter.apply(tgt) : tgt;