[JAVA-3273] Ability to configure replacement for dot in a Map<String, Object> Created: 23/Apr/19  Updated: 16/Nov/21  Resolved: 29/Apr/19

Status: Closed
Project: Java Driver
Component/s: Codecs
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Satyaprakash Reddy Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by JAVA-2810 Allow dots and $ in field names Closed
Related
related to SERVER-30575 Please add escaping convention for do... Backlog
is related to DRIVERS-618 Add escaping convention for dot and d... Closed

 Description   

Background

There are multiple ways to store a nested document in mongodb with dot in field names.

  1. Serialize the whole document as a string and store it.
  2. Since MongoDB have restrictions on only top level fields containing dot, we can wrap the entire document in another document whose only field name doesn't have a dot. While returning data, we can always query internal document of interest and return it.

But the important abilities we might loose are querying and patching of nested fields.

To be able to retain these two, we might have to replace dot character with some decent character sequence and persist it. Today, there is no easy way to specify a replacement for dot in codecs.

For e.g. Spring data for mongodb provides an easy way to do this:

Documentation:

https://docs.spring.io/spring-data/mongodb/docs/current/api/org/springframework/data/mongodb/core/convert/MappingMongoConverter.html#setMapKeyDotReplacement-java.lang.String-

 

Ask

It would be good to provide an easy knob to set replacement for special characters(dot and dollar to start with) and all the codecs should replace those special characters in the property names.

 

 



 Comments   
Comment by Ian Whalen (Inactive) [ 29/Apr/19 ]

satyaprakash.vennapusa thanks for the change request - we're aware of the general requirement users have but don't necessarily plan to fix it in this way. Please follow DRIVERS-618 as we design and implement our desired solution across all of the MongoDB drivers.

Generated at Thu Feb 08 08:59:12 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.